Skip to content

Commit

Permalink
Replace filepath IsAbs with own util IsRemotePath
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishnaDeqode committed Jan 28, 2020
1 parent 6be40c6 commit ef75242
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (a *Allocation) uploadOrUpdateFile(localpath string, remotepath string, sta
}

remotepath = filepath.Clean(remotepath)
isabs := filepath.IsAbs(remotepath)
isabs := zboxutil.IsRemoteAbs(remotepath)
if !isabs {
return common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func (a *Allocation) ListDir(path string) (*ListResult, error) {
return nil, common.NewError("invalid_path", "Invalid path for the list")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return nil, common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand Down Expand Up @@ -431,7 +431,7 @@ func (a *Allocation) GetFileStats(path string) (map[string]*FileStats, error) {
return nil, common.NewError("invalid_path", "Invalid path for the list")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return nil, common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand Down Expand Up @@ -460,7 +460,7 @@ func (a *Allocation) DeleteFile(path string) error {
return common.NewError("invalid_path", "Invalid path for the list")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand All @@ -487,7 +487,7 @@ func (a *Allocation) RenameObject(path string, destName string) error {
return common.NewError("invalid_path", "Invalid path for the list")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand All @@ -514,7 +514,7 @@ func (a *Allocation) CopyObject(path string, destPath string) error {
return common.NewError("invalid_path", "Invalid path for copy")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand Down Expand Up @@ -545,7 +545,7 @@ func (a *Allocation) GetAuthTicket(path string, filename string, referenceType s
return "", common.NewError("invalid_path", "Invalid path for the list")
}
path = filepath.Clean(path)
isabs := filepath.IsAbs(path)
isabs := zboxutil.IsRemoteAbs(path)
if !isabs {
return "", common.NewError("invalid_path", "Path should be valid and absolute")
}
Expand Down
4 changes: 4 additions & 0 deletions zboxcore/zboxutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ func NewConnectionId() string {
}
return fmt.Sprintf("%d", nBig.Int64())
}

func IsRemoteAbs(path string) bool {
return strings.HasPrefix(path, "/")
}

0 comments on commit ef75242

Please sign in to comment.