diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-09-09 02:48:58 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-09-09 02:48:58 -0700 |
| commit | 9b3bf0e46c65ab8dfa980750cb1b805f08383df9 (patch) | |
| tree | c5a6ac0eda11e72f6fde12080457a4200abd11a1 | |
| parent | bc8d34143d1265a58a04073c9edd394a70b83dcb (diff) | |
| download | seaweedfs-9b3bf0e46c65ab8dfa980750cb1b805f08383df9.tar.xz seaweedfs-9b3bf0e46c65ab8dfa980750cb1b805f08383df9.zip | |
fix "weed backup" rerunning
"weed backup" rerunning will already have ReplicaPlacement set, while version is not set.
| -rw-r--r-- | weed/storage/volume_loading.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go index 572220650..37a6e07b2 100644 --- a/weed/storage/volume_loading.go +++ b/weed/storage/volume_loading.go @@ -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 } |
