mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-02 23:27:26 -04:00
Remove verifyOldLocationExists parameter from RenameLocal()
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ func main() {
|
|||||||
// stdin[0] is evaluated after fallthrough
|
// stdin[0] is evaluated after fallthrough
|
||||||
// stdin[1] is expected to be the OLD incomplete target location with FSPath representing path separators - Always pass in UNIX format
|
// stdin[1] is expected to be the OLD incomplete target location with FSPath representing path separators - Always pass in UNIX format
|
||||||
// stdin[2] is expected to be the NEW incomplete target location with FSPath representing path separators - Always pass in UNIX format
|
// stdin[2] is expected to be the NEW incomplete target location with FSPath representing path separators - Always pass in UNIX format
|
||||||
_ = synccommon.RenameLocal(strings.ReplaceAll(stdin[1], global.FSPath, "/"), strings.ReplaceAll(stdin[2], global.FSPath, "/"), true)
|
_ = synccommon.RenameLocal(strings.ReplaceAll(stdin[1], global.FSPath, "/"), strings.ReplaceAll(stdin[2], global.FSPath, "/"))
|
||||||
fallthrough // fallthrough to add the old entry to the deletions directory
|
fallthrough // fallthrough to add the old entry to the deletions directory
|
||||||
case "shear":
|
case "shear":
|
||||||
// shear an entry from the server and add it to the deletions directory
|
// shear an entry from the server and add it to the deletions directory
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ end:
|
|||||||
// It can safely be called in offline mode, as well, so this is the intended
|
// It can safely be called in offline mode, as well, so this is the intended
|
||||||
// interface for renaming (RenameLocal should only be used directly by the server binary).
|
// interface for renaming (RenameLocal should only be used directly by the server binary).
|
||||||
func RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete string) error {
|
func RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete string) error {
|
||||||
err := synccommon.RenameLocal(oldLocationIncomplete, newLocationIncomplete, false) // move the target on the local system
|
err := synccommon.RenameLocal(oldLocationIncomplete, newLocationIncomplete) // move the target on the local system
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("unable to rename target locally: " + err.Error())
|
return errors.New("unable to rename target locally: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,18 +89,11 @@ func ShearLocal(targetLocationIncomplete, clientDeviceID string) (string, bool,
|
|||||||
|
|
||||||
// RenameLocal renames oldLocationIncomplete to newLocationIncomplete on the local system.
|
// RenameLocal renames oldLocationIncomplete to newLocationIncomplete on the local system.
|
||||||
// This function should only be used directly by the server binary.
|
// This function should only be used directly by the server binary.
|
||||||
func RenameLocal(oldLocationIncomplete, newLocationIncomplete string, verifyOldLocationExists bool) error {
|
func RenameLocal(oldLocationIncomplete, newLocationIncomplete string) error {
|
||||||
// get full paths for both locations
|
// get full paths for both locations
|
||||||
oldLocation := global.TargetLocationFormat(oldLocationIncomplete)
|
oldLocation := global.TargetLocationFormat(oldLocationIncomplete)
|
||||||
newLocation := global.TargetLocationFormat(newLocationIncomplete)
|
newLocation := global.TargetLocationFormat(newLocationIncomplete)
|
||||||
|
|
||||||
if verifyOldLocationExists {
|
|
||||||
isAccessible, _ := back.TargetIsFile(oldLocation, true) // error is ignored because dir/file status is irrelevant
|
|
||||||
if !isAccessible {
|
|
||||||
return errors.New("old target (" + oldLocation + ") does not exist")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure newLocation does not exist
|
// ensure newLocation does not exist
|
||||||
isAccessible, _ := back.TargetIsFile(newLocation, true) // error is ignored because dir/file status is irrelevant
|
isAccessible, _ := back.TargetIsFile(newLocation, true) // error is ignored because dir/file status is irrelevant
|
||||||
if isAccessible {
|
if isAccessible {
|
||||||
|
|||||||
Reference in New Issue
Block a user