mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix "weed backup" rerunning
"weed backup" rerunning will already have ReplicaPlacement set, while version is not set.
This commit is contained in:
parent
bc8d34143d
commit
9b3bf0e46c
|
@ -19,8 +19,9 @@ func loadVolumeWithoutIndex(dirname string, collection string, id VolumeId, need
|
|||
func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind NeedleMapType, preallocate int64) error {
|
||||
var e error
|
||||
fileName := v.FileName()
|
||||
alreadyHasSuperBlock := false
|
||||
|
||||
if exists, canRead, canWrite, modifiedTime := checkFile(fileName + ".dat"); exists {
|
||||
if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists {
|
||||
if !canRead {
|
||||
return fmt.Errorf("cannot read Volume Data file %s.dat", fileName)
|
||||
}
|
||||
|
@ -32,6 +33,9 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||
v.dataFile, e = os.Open(fileName + ".dat")
|
||||
v.readOnly = true
|
||||
}
|
||||
if fileSize >= _SuperBlockSize {
|
||||
alreadyHasSuperBlock = true
|
||||
}
|
||||
} else {
|
||||
if createDatIfMissing {
|
||||
v.dataFile, e = createVolumeFile(fileName+".dat", preallocate)
|
||||
|
@ -48,7 +52,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||
}
|
||||
}
|
||||
|
||||
if v.ReplicaPlacement == nil {
|
||||
if alreadyHasSuperBlock {
|
||||
e = v.readSuperBlock()
|
||||
} else {
|
||||
e = v.maybeWriteSuperBlock()
|
||||
|
@ -97,7 +101,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||
return e
|
||||
}
|
||||
|
||||
func checkFile(filename string) (exists, canRead, canWrite bool, modTime time.Time) {
|
||||
func checkFile(filename string) (exists, canRead, canWrite bool, modTime time.Time, fileSize int64) {
|
||||
exists = true
|
||||
fi, err := os.Stat(filename)
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -111,5 +115,6 @@ func checkFile(filename string) (exists, canRead, canWrite bool, modTime time.Ti
|
|||
canWrite = true
|
||||
}
|
||||
modTime = fi.ModTime()
|
||||
fileSize = fi.Size()
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue