mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-09-03 15:47:27 -04:00
Fix rename prompting for new location before verifying old one exists
This commit is contained in:
+1
-1
@@ -414,7 +414,7 @@ func ShearRemoteFromClient(targetLocationIncomplete string) {
|
|||||||
// RenameRemoteFromClient renames oldLocationIncomplete to newLocationIncomplete on the local system and calls the server to perform the rename remotely and add the old target to the deletions list
|
// RenameRemoteFromClient renames oldLocationIncomplete to newLocationIncomplete on the local system and calls the server to perform the rename remotely and add the old target to the deletions list
|
||||||
// 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)
|
// 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)
|
||||||
func RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete string) {
|
func RenameRemoteFromClient(oldLocationIncomplete, newLocationIncomplete string) {
|
||||||
RenameLocal(oldLocationIncomplete, newLocationIncomplete) // move the target on the local system
|
RenameLocal(oldLocationIncomplete, newLocationIncomplete, false) // move the target on the local system
|
||||||
|
|
||||||
deviceIDList := genDeviceIDList()
|
deviceIDList := genDeviceIDList()
|
||||||
if len(*deviceIDList) > 0 { // ensure a device ID exists (online mode)
|
if len(*deviceIDList) > 0 { // ensure a device ID exists (online mode)
|
||||||
|
|||||||
+6
-4
@@ -2,10 +2,11 @@ package sync
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rwinkhart/MUTN/src/backend"
|
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rwinkhart/MUTN/src/backend"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getModTimes returns a list of all entry modification times
|
// getModTimes returns a list of all entry modification times
|
||||||
@@ -78,13 +79,14 @@ func ShearLocal(targetLocationIncomplete, clientDeviceID string) string {
|
|||||||
|
|
||||||
// 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) {
|
func RenameLocal(oldLocationIncomplete, newLocationIncomplete string, verifyOldLocationExists bool) {
|
||||||
// get full paths for both locations
|
// get full paths for both locations
|
||||||
oldLocation := backend.TargetLocationFormat(oldLocationIncomplete)
|
oldLocation := backend.TargetLocationFormat(oldLocationIncomplete)
|
||||||
newLocation := backend.TargetLocationFormat(newLocationIncomplete)
|
newLocation := backend.TargetLocationFormat(newLocationIncomplete)
|
||||||
|
|
||||||
// ensure oldLocation exists
|
if verifyOldLocationExists {
|
||||||
backend.TargetIsFile(oldLocation, true, 0)
|
backend.TargetIsFile(oldLocation, true, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// ensure newLocation does not exist
|
// ensure newLocation does not exist
|
||||||
_, isAccessible := backend.TargetIsFile(newLocation, false, 0)
|
_, isAccessible := backend.TargetIsFile(newLocation, false, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user