Ignore io.EOF for gob decoding

This commit is contained in:
Harshavardhana
2014-12-11 01:45:58 -08:00
parent 063d668133
commit c0724b38b9
3 changed files with 36 additions and 38 deletions
+3 -3
View File
@@ -24,7 +24,7 @@ type Header struct {
Path string
Offset int64
Length int
Crc []byte
Crc uint32
}
func NewStorage(rootDir string, slice int) (storage.ObjectStorage, error) {
@@ -44,7 +44,7 @@ func NewStorage(rootDir string, slice int) (storage.ObjectStorage, error) {
}
dec := gob.NewDecoder(mapFile)
err = dec.Decode(&objects)
if err != nil {
if err != nil && err != io.EOF {
return &appendStorage{}, nil
}
}
@@ -81,7 +81,7 @@ func (aStorage *appendStorage) Put(objectPath string, object io.Reader) error {
Path: objectPath,
Offset: 0,
Length: 0,
Crc: nil,
Crc: 0,
}
offset, err := aStorage.file.Seek(0, os.SEEK_END)
if err != nil {