Skip to content

Commit e3d69c0

Browse files
committed
Windows path fix
1 parent 74a2120 commit e3d69c0

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

zboxcore/allocationchange/copyobject.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/0chain/gosdk/core/common"
77
"github.com/0chain/gosdk/zboxcore/fileref"
8+
"github.com/0chain/gosdk/zboxcore/zboxutil"
89
)
910

1011
type CopyFileChange struct {
@@ -58,7 +59,7 @@ func (ch *CopyFileChange) ProcessChange(rootRef *fileref.Ref) error {
5859
affectedRef = ch.ObjectTree.(*fileref.Ref)
5960
}
6061

61-
affectedRef.Path = filepath.Join(foundRef.GetPath(), affectedRef.Name)
62+
affectedRef.Path = zboxutil.Join(foundRef.GetPath(), affectedRef.Name)
6263
ch.processChildren(affectedRef)
6364

6465
destRef := foundRef.(*fileref.Ref)
@@ -76,7 +77,7 @@ func (ch *CopyFileChange) processChildren(curRef *fileref.Ref) {
7677
} else {
7778
childRef = childRefEntity.(*fileref.Ref)
7879
}
79-
childRef.Path = filepath.Join(curRef.Path, childRef.Name)
80+
childRef.Path = zboxutil.Join(curRef.Path, childRef.Name)
8081
if childRefEntity.GetType() == fileref.DIRECTORY {
8182
ch.processChildren(childRef)
8283
}

zboxcore/allocationchange/renameobject.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/0chain/gosdk/core/common"
77
"github.com/0chain/gosdk/zboxcore/fileref"
8+
"github.com/0chain/gosdk/zboxcore/zboxutil"
89
)
910

1011
type RenameFileChange struct {
@@ -55,9 +56,9 @@ func (ch *RenameFileChange) ProcessChange(rootRef *fileref.Ref) error {
5556
}
5657

5758
path, _ = filepath.Split(affectedRef.Path)
58-
path = filepath.Clean(path)
59+
path = zboxutil.RemoteClean(path)
5960
affectedRef.Name = ch.NewName
60-
affectedRef.Path = filepath.Join(path, ch.NewName)
61+
affectedRef.Path = zboxutil.Join(path, ch.NewName)
6162

6263
// Logger.Info("Changed name: " + dirRef.Children[idx].GetName())
6364

zboxcore/zboxutil/util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,7 @@ func getMinShardersVerify() int {
207207
func calculateMinRequired(minRequired, percent float64) int {
208208
return int(math.Ceil(minRequired * percent))
209209
}
210+
211+
func Join(a, b string) string {
212+
return strings.ReplaceAll(filepath.Join(a, b), "\\", "/")
213+
}

0 commit comments

Comments
 (0)