aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/fullpath.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@uber.com>2019-03-30 23:08:29 -0700
committerChris Lu <chris.lu@uber.com>2019-03-30 23:08:29 -0700
commit97406333a5ecc5b0d2cdaa74ff9901e3100e4bf2 (patch)
tree04cb10ddb0fb87663ba1783a7e82397aa2c9c06f /weed/filer2/fullpath.go
parent920b4e56aa76fbf37780363d5b345c2882d311b5 (diff)
downloadseaweedfs-97406333a5ecc5b0d2cdaa74ff9901e3100e4bf2.tar.xz
seaweedfs-97406333a5ecc5b0d2cdaa74ff9901e3100e4bf2.zip
support atomic renaming for mysql/postgres filer store
Diffstat (limited to 'weed/filer2/fullpath.go')
-rw-r--r--weed/filer2/fullpath.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/weed/filer2/fullpath.go b/weed/filer2/fullpath.go
index be6e34431..191e51cf3 100644
--- a/weed/filer2/fullpath.go
+++ b/weed/filer2/fullpath.go
@@ -8,10 +8,7 @@ import (
type FullPath string
func NewFullPath(dir, name string) FullPath {
- if strings.HasSuffix(dir, "/") {
- return FullPath(dir + name)
- }
- return FullPath(dir + "/" + name)
+ return FullPath(dir).Child(name)
}
func (fp FullPath) DirAndName() (string, string) {
@@ -29,3 +26,11 @@ func (fp FullPath) Name() string {
_, name := filepath.Split(string(fp))
return name
}
+
+func (fp FullPath) Child(name string) FullPath {
+ dir := string(fp)
+ if strings.HasSuffix(dir, "/") {
+ return FullPath(dir + name)
+ }
+ return FullPath(dir + "/" + name)
+}