mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-07-31 20:36:08 +08:00
volume: return error if superblock is not initialized
fix https://github.com/chrislusf/seaweedfs/issues/1079
This commit is contained in:
parent
a999ed94d0
commit
09874f0d16
@ -59,6 +59,9 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||||||
if alreadyHasSuperBlock {
|
if alreadyHasSuperBlock {
|
||||||
e = v.readSuperBlock()
|
e = v.readSuperBlock()
|
||||||
} else {
|
} else {
|
||||||
|
if !v.SuperBlock.Initialized() {
|
||||||
|
return fmt.Errorf("volume %s.dat not initialized", fileName)
|
||||||
|
}
|
||||||
e = v.maybeWriteSuperBlock()
|
e = v.maybeWriteSuperBlock()
|
||||||
}
|
}
|
||||||
if e == nil && alsoLoadIndex {
|
if e == nil && alsoLoadIndex {
|
||||||
|
@ -69,6 +69,10 @@ func (s *SuperBlock) Bytes() []byte {
|
|||||||
return header
|
return header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SuperBlock) Initialized() bool {
|
||||||
|
return s.ReplicaPlacement == nil || s.Ttl == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Volume) maybeWriteSuperBlock() error {
|
func (v *Volume) maybeWriteSuperBlock() error {
|
||||||
stat, e := v.dataFile.Stat()
|
stat, e := v.dataFile.Stat()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user