SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
resolve directories if containing home directory
Chris Luf43146b237bc
diff --git a/weed/command/backup.go b/weed/command/backup.goindex 615be80cf0..950cbf68eb 100644--- a/weed/command/backup.go+++ b/weed/command/backup.go@@ -112,7 +112,7 @@ func runBackup(cmd *Command, args []string) bool {return true}}- v, err := storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, 0)+ v, err := storage.NewVolume(util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, 0)if err != nil {fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)return true@@ -137,7 +137,7 @@ func runBackup(cmd *Command, args []string) bool {// remove the old datav.Destroy()// recreate an empty volume- v, err = storage.NewVolume(*s.dir, *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, 0)+ v, err = storage.NewVolume(util.ResolvePath(*s.dir), *s.collection, vid, storage.NeedleMapInMemory, replication, ttl, 0, 0)if err != nil {fmt.Printf("Error creating or reading from volume %d: %v\n", vid, err)return truediff --git a/weed/command/compact.go b/weed/command/compact.goindex 4e28aa7255..6117cf9f32 100644--- a/weed/command/compact.go+++ b/weed/command/compact.go@@ -4,6 +4,7 @@ import ("github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/storage""github.com/chrislusf/seaweedfs/weed/storage/needle"+ "github.com/chrislusf/seaweedfs/weed/util")func init() {@@ -40,7 +41,7 @@ func runCompact(cmd *Command, args []string) bool {preallocate := *compactVolumePreallocate * (1 << 20)vid := needle.VolumeId(*compactVolumeId)- v, err := storage.NewVolume(*compactVolumePath, *compactVolumeCollection, vid,+ v, err := storage.NewVolume(util.ResolvePath(*compactVolumePath), *compactVolumeCollection, vid,storage.NeedleMapInMemory, nil, nil, preallocate, 0)if err != nil {glog.Fatalf("Load Volume [ERROR] %s\n", err)diff --git a/weed/command/download.go b/weed/command/download.goindex be0eb47e57..7d4dad2d44 100644--- a/weed/command/download.go+++ b/weed/command/download.go@@ -43,7 +43,7 @@ var cmdDownload = &Command{func runDownload(cmd *Command, args []string) bool {for _, fid := range args {- if e := downloadToFile(*d.server, fid, *d.dir); e != nil {+ if e := downloadToFile(*d.server, fid, util.ResolvePath(*d.dir)); e != nil {fmt.Println("Download Error: ", fid, e)}}diff --git a/weed/command/export.go b/weed/command/export.goindex 5d304b5a06..411d231cbb 100644--- a/weed/command/export.go+++ b/weed/command/export.go@@ -198,7 +198,7 @@ func runExport(cmd *Command, args []string) bool {needleMap := needle_map.NewMemDb()defer needleMap.Close()- if err := needleMap.LoadFromIdx(path.Join(*export.dir, fileName+".idx")); err != nil {+ if err := needleMap.LoadFromIdx(path.Join(util.ResolvePath(*export.dir), fileName+".idx")); err != nil {glog.Fatalf("cannot load needle map from %s.idx: %s", fileName, err)}@@ -211,7 +211,7 @@ func runExport(cmd *Command, args []string) bool {fmt.Printf("key\tname\tsize\tgzip\tmime\tmodified\tttl\tdeleted\n")}- err = storage.ScanVolumeFile(*export.dir, *export.collection, vid, storage.NeedleMapInMemory, volumeFileScanner)+ err = storage.ScanVolumeFile(util.ResolvePath(*export.dir), *export.collection, vid, storage.NeedleMapInMemory, volumeFileScanner)if err != nil && err != io.EOF {glog.Fatalf("Export Volume File [ERROR] %s\n", err)}diff --git a/weed/command/filer.go b/weed/command/filer.goindex b52b011498..c36c43e93e 100644--- a/weed/command/filer.go+++ b/weed/command/filer.go@@ -100,7 +100,7 @@ func (fo *FilerOptions) startFiler() {defaultLevelDbDirectory := "./filerldb2"if fo.defaultLevelDbDirectory != nil {- defaultLevelDbDirectory = *fo.defaultLevelDbDirectory + "/filerldb2"+ defaultLevelDbDirectory = util.ResolvePath(*fo.defaultLevelDbDirectory + "/filerldb2")}var peers []stringdiff --git a/weed/command/fix.go b/weed/command/fix.goindex 223808f4bc..e1455790f3 100644--- a/weed/command/fix.go+++ b/weed/command/fix.go@@ -11,6 +11,7 @@ import ("github.com/chrislusf/seaweedfs/weed/storage/needle_map""github.com/chrislusf/seaweedfs/weed/storage/super_block""github.com/chrislusf/seaweedfs/weed/storage/types"+ "github.com/chrislusf/seaweedfs/weed/util")func init() {@@ -67,7 +68,7 @@ func runFix(cmd *Command, args []string) bool {if *fixVolumeCollection != "" {baseFileName = *fixVolumeCollection + "_" + baseFileName}- indexFileName := path.Join(*fixVolumePath, baseFileName+".idx")+ indexFileName := path.Join(util.ResolvePath(*fixVolumePath), baseFileName+".idx")nm := needle_map.NewMemDb()defer nm.Close()@@ -77,7 +78,7 @@ func runFix(cmd *Command, args []string) bool {nm: nm,}- if err := storage.ScanVolumeFile(*fixVolumePath, *fixVolumeCollection, vid, storage.NeedleMapInMemory, scanner); err != nil {+ if err := storage.ScanVolumeFile(util.ResolvePath(*fixVolumePath), *fixVolumeCollection, vid, storage.NeedleMapInMemory, scanner); err != nil {glog.Fatalf("scan .dat File: %v", err)os.Remove(indexFileName)}diff --git a/weed/command/master.go b/weed/command/master.goindex 7cbd66f5c5..a6fe744d77 100644--- a/weed/command/master.go+++ b/weed/command/master.go@@ -8,10 +8,11 @@ import ("strings""github.com/chrislusf/raft/protobuf"- "github.com/chrislusf/seaweedfs/weed/util/grace""github.com/gorilla/mux""google.golang.org/grpc/reflection"+ "github.com/chrislusf/seaweedfs/weed/util/grace"+"github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/pb""github.com/chrislusf/seaweedfs/weed/pb/master_pb"@@ -85,7 +86,7 @@ func runMaster(cmd *Command, args []string) bool {runtime.GOMAXPROCS(runtime.NumCPU())grace.SetupProfiling(*masterCpuProfile, *masterMemProfile)- if err := util.TestFolderWritable(*m.metaFolder); err != nil {+ if err := util.TestFolderWritable(util.ResolvePath(*m.metaFolder)); err != nil {glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err)}@@ -118,7 +119,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {}// start raftServerraftServer := weed_server.NewRaftServer(security.LoadClientTLS(util.GetViper(), "grpc.master"),- peers, myMasterAddress, *masterOption.metaFolder, ms.Topo, 5)+ peers, myMasterAddress, util.ResolvePath(*masterOption.metaFolder), ms.Topo, 5)if raftServer == nil {glog.Fatalf("please verify %s is writable, see https://github.com/chrislusf/seaweedfs/issues/717", *masterOption.metaFolder)}diff --git a/weed/command/server.go b/weed/command/server.goindex 8bc98b900a..565563c773 100644--- a/weed/command/server.go+++ b/weed/command/server.go@@ -176,7 +176,7 @@ func runServer(cmd *Command, args []string) bool {if *masterOptions.metaFolder == "" {*masterOptions.metaFolder = folders[0]}- if err := util.TestFolderWritable(*masterOptions.metaFolder); err != nil {+ if err := util.TestFolderWritable(util.ResolvePath(*masterOptions.metaFolder)); err != nil {glog.Fatalf("Check Meta Folder (-mdir=\"%s\") Writable: %s", *masterOptions.metaFolder, err)}filerOptions.defaultLevelDbDirectory = masterOptions.metaFolderdiff --git a/weed/command/upload.go b/weed/command/upload.goindex 358897aee3..45b15535b9 100644--- a/weed/command/upload.go+++ b/weed/command/upload.go@@ -69,7 +69,7 @@ func runUpload(cmd *Command, args []string) bool {if *upload.dir == "" {return false}- filepath.Walk(*upload.dir, func(path string, info os.FileInfo, err error) error {+ filepath.Walk(util.ResolvePath(*upload.dir), func(path string, info os.FileInfo, err error) error {if err == nil {if !info.IsDir() {if *upload.include != "" {diff --git a/weed/command/volume.go b/weed/command/volume.goindex 27687af664..4f04a467d6 100644--- a/weed/command/volume.go+++ b/weed/command/volume.go@@ -117,7 +117,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v// Set multiple folders and each folder's max volume count limit'v.folders = strings.Split(volumeFolders, ",")for _, folder := range v.folders {- if err := util.TestFolderWritable(folder); err != nil {+ if err := util.TestFolderWritable(util.ResolvePath(folder)); err != nil {glog.Fatalf("Check Data Folder(-dir) Writable %s : %s", folder, err)}}diff --git a/weed/command/webdav.go b/weed/command/webdav.goindex b9676c9092..dc84b1fd06 100644--- a/weed/command/webdav.go+++ b/weed/command/webdav.go@@ -110,7 +110,7 @@ func (wo *WebDavOption) startWebDav() bool {Uid: uid,Gid: gid,Cipher: cipher,- CacheDir: *wo.cacheDir,+ CacheDir: util.ResolvePath(*wo.cacheDir),CacheSizeMB: *wo.cacheSizeMB,})if webdavServer_err != nil {diff --git a/weed/storage/store.go b/weed/storage/store.goindex 0ac3381c5b..02372da97f 100644--- a/weed/storage/store.go+++ b/weed/storage/store.go@@ -16,6 +16,7 @@ import ("github.com/chrislusf/seaweedfs/weed/storage/needle""github.com/chrislusf/seaweedfs/weed/storage/super_block". "github.com/chrislusf/seaweedfs/weed/storage/types"+ "github.com/chrislusf/seaweedfs/weed/util")const (@@ -28,13 +29,13 @@ const (type Store struct {MasterAddress stringgrpcDialOption grpc.DialOption- volumeSizeLimit uint64 //read from the master+ volumeSizeLimit uint64 // read from the masterIp stringPort intPublicUrl stringLocations []*DiskLocation- dataCenter string //optional informaton, overwriting master setting if exists- rack string //optional information, overwriting master setting if exists+ dataCenter string // optional informaton, overwriting master setting if exists+ rack string // optional information, overwriting master setting if existsconnected boolNeedleMapType NeedleMapTypeNewVolumesChan chan master_pb.VolumeShortInformationMessage@@ -52,7 +53,7 @@ func NewStore(grpcDialOption grpc.DialOption, port int, ip, publicUrl string, dis = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, PublicUrl: publicUrl, NeedleMapType: needleMapKind}s.Locations = make([]*DiskLocation, 0)for i := 0; i < len(dirnames); i++ {- location := NewDiskLocation(dirnames[i], maxVolumeCounts[i], minFreeSpacePercents[i])+ location := NewDiskLocation(util.ResolvePath(dirnames[i]), maxVolumeCounts[i], minFreeSpacePercents[i])location.loadExistingVolumes(needleMapKind)s.Locations = append(s.Locations, location)stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i]))