Skip to content

Commit

Permalink
Windows path fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishnaDeqode committed Sep 3, 2020
1 parent 74a2120 commit e3d69c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions zboxcore/allocationchange/copyobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/0chain/gosdk/core/common"
"github.com/0chain/gosdk/zboxcore/fileref"
"github.com/0chain/gosdk/zboxcore/zboxutil"
)

type CopyFileChange struct {
Expand Down Expand Up @@ -58,7 +59,7 @@ func (ch *CopyFileChange) ProcessChange(rootRef *fileref.Ref) error {
affectedRef = ch.ObjectTree.(*fileref.Ref)
}

affectedRef.Path = filepath.Join(foundRef.GetPath(), affectedRef.Name)
affectedRef.Path = zboxutil.Join(foundRef.GetPath(), affectedRef.Name)
ch.processChildren(affectedRef)

destRef := foundRef.(*fileref.Ref)
Expand All @@ -76,7 +77,7 @@ func (ch *CopyFileChange) processChildren(curRef *fileref.Ref) {
} else {
childRef = childRefEntity.(*fileref.Ref)
}
childRef.Path = filepath.Join(curRef.Path, childRef.Name)
childRef.Path = zboxutil.Join(curRef.Path, childRef.Name)
if childRefEntity.GetType() == fileref.DIRECTORY {
ch.processChildren(childRef)
}
Expand Down
5 changes: 3 additions & 2 deletions zboxcore/allocationchange/renameobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/0chain/gosdk/core/common"
"github.com/0chain/gosdk/zboxcore/fileref"
"github.com/0chain/gosdk/zboxcore/zboxutil"
)

type RenameFileChange struct {
Expand Down Expand Up @@ -55,9 +56,9 @@ func (ch *RenameFileChange) ProcessChange(rootRef *fileref.Ref) error {
}

path, _ = filepath.Split(affectedRef.Path)
path = filepath.Clean(path)
path = zboxutil.RemoteClean(path)
affectedRef.Name = ch.NewName
affectedRef.Path = filepath.Join(path, ch.NewName)
affectedRef.Path = zboxutil.Join(path, ch.NewName)

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

Expand Down
4 changes: 4 additions & 0 deletions zboxcore/zboxutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,7 @@ func getMinShardersVerify() int {
func calculateMinRequired(minRequired, percent float64) int {
return int(math.Ceil(minRequired * percent))
}

func Join(a, b string) string {
return strings.ReplaceAll(filepath.Join(a, b), "\\", "/")
}

0 comments on commit e3d69c0

Please sign in to comment.