Browse Source

volume: return error if superblock is not initialized

fix https://github.com/chrislusf/seaweedfs/issues/1079
pull/1084/head
Chris Lu 5 years ago
parent
commit
09874f0d16
  1. 3
      weed/storage/volume_loading.go
  2. 4
      weed/storage/volume_super_block.go

3
weed/storage/volume_loading.go

@ -59,6 +59,9 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
if alreadyHasSuperBlock {
e = v.readSuperBlock()
} else {
if !v.SuperBlock.Initialized() {
return fmt.Errorf("volume %s.dat not initialized", fileName)
}
e = v.maybeWriteSuperBlock()
}
if e == nil && alsoLoadIndex {

4
weed/storage/volume_super_block.go

@ -69,6 +69,10 @@ func (s *SuperBlock) Bytes() []byte {
return header
}
func (s *SuperBlock) Initialized() bool {
return s.ReplicaPlacement == nil || s.Ttl == nil
}
func (v *Volume) maybeWriteSuperBlock() error {
stat, e := v.dataFile.Stat()
if e != nil {

Loading…
Cancel
Save