From 7719bb9f297660c6bad5129dfd5a60da708b54d6 Mon Sep 17 00:00:00 2001 From: Richard Sanger Date: Wed, 27 Nov 2019 00:00:40 +1300 Subject: [PATCH] Fix: backup to shared drive root Allows writing to the drive root using: gcd://driveid@ or gcd://driveid@/ To write to the root of the default user's drive use the special shared drive named 'root': gcd://root@/ --- src/duplicacy_gcdstorage.go | 5 +++++ src/duplicacy_storage.go | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/duplicacy_gcdstorage.go b/src/duplicacy_gcdstorage.go index c29270d..c04aff2 100644 --- a/src/duplicacy_gcdstorage.go +++ b/src/duplicacy_gcdstorage.go @@ -264,6 +264,11 @@ func (storage *GCDStorage) getIDFromPath(threadIndex int, filePath string, creat fileID = rootID } + // Write directly to the root of the drive + if filePath == "" { + return fileID, nil + } + names := strings.Split(filePath, "/") current := "" for i, name := range names { diff --git a/src/duplicacy_storage.go b/src/duplicacy_storage.go index 9655da3..8c32032 100644 --- a/src/duplicacy_storage.go +++ b/src/duplicacy_storage.go @@ -582,8 +582,13 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor SavePassword(preference, "gcs_token", tokenFile) return gcsStorage } else if matched[1] == "gcd" { + // Handle writing directly to the root of the drive + // For gcd://driveid@/, driveid@ is match[3] not match[2] + if matched[2] == "" && strings.HasSuffix(matched[3], "@") { + matched[2], matched[3] = matched[3], matched[2] + } driveID := matched[2] - if len(driveID) != 0 { + if driveID != "" { driveID = driveID[:len(driveID)-1] } storagePath := matched[3] + matched[4]