aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/volume_loading.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-12-28 12:28:58 -0800
committerChris Lu <chris.lu@gmail.com>2019-12-28 12:28:58 -0800
commitc06f7eb48a82afee597e2f2a193a36c8058915eb (patch)
treef4e8e61ef155f395c529bc2e49eecf8e5f66c6ab /weed/storage/volume_loading.go
parentb7bc08cf52fa8471c76310b04200abb5ee4bf531 (diff)
downloadseaweedfs-c06f7eb48a82afee597e2f2a193a36c8058915eb.tar.xz
seaweedfs-c06f7eb48a82afee597e2f2a193a36c8058915eb.zip
load volume info from .vif file, use superblock as a backup
Diffstat (limited to 'weed/storage/volume_loading.go')
-rw-r--r--weed/storage/volume_loading.go21
1 files changed, 2 insertions, 19 deletions
diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.go
index 9a99c5366..3ddf54bae 100644
--- a/weed/storage/volume_loading.go
+++ b/weed/storage/volume_loading.go
@@ -3,7 +3,6 @@ package storage
import (
"fmt"
"os"
- "time"
"github.com/syndtr/goleveldb/leveldb/opt"
@@ -12,6 +11,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/storage/backend"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
"github.com/chrislusf/seaweedfs/weed/storage/super_block"
+ "github.com/chrislusf/seaweedfs/weed/util"
)
func loadVolumeWithoutIndex(dirname string, collection string, id needle.VolumeId, needleMapKind NeedleMapType) (v *Volume, err error) {
@@ -34,7 +34,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
glog.V(0).Infof("loading volume %d from remote %v", v.Id, v.volumeInfo.Files)
v.LoadRemoteFile()
alreadyHasSuperBlock = true
- } else if exists, canRead, canWrite, modifiedTime, fileSize := checkFile(fileName + ".dat"); exists {
+ } else if exists, canRead, canWrite, modifiedTime, fileSize := util.CheckFile(fileName + ".dat"); exists {
// open dat file
if !canRead {
return fmt.Errorf("cannot read Volume Data file %s.dat", fileName)
@@ -144,20 +144,3 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
return err
}
-func checkFile(filename string) (exists, canRead, canWrite bool, modTime time.Time, fileSize int64) {
- exists = true
- fi, err := os.Stat(filename)
- if os.IsNotExist(err) {
- exists = false
- return
- }
- if fi.Mode()&0400 != 0 {
- canRead = true
- }
- if fi.Mode()&0200 != 0 {
- canWrite = true
- }
- modTime = fi.ModTime()
- fileSize = fi.Size()
- return
-}