Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

bisync: provide more info in critical error msgs

nielash4d5d6ee61b2f
diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go
index 185981a2c..d0ce2e225 100644
--- a/cmd/bisync/bisync_test.go
+++ b/cmd/bisync/bisync_test.go
@@ -1231,6 +1231,7 @@ func (b *bisyncTest) newReplacer(mangle bool) *strings.Replacer {
"//?/" + strings.TrimSuffix(strings.Replace(b.path2, slash, "/", -1), "/"), "{path2}",
strings.TrimSuffix(b.path1, slash), "{path1}", // ensure it's still recognized without trailing slash
strings.TrimSuffix(b.path2, slash), "{path2}",
+ b.workDir, "{workdir}",
b.sessionName, "{session}",
}
if fixSlash {
diff --git a/cmd/bisync/operations.go b/cmd/bisync/operations.go
index 00d879dbc..a49aa6442 100644
--- a/cmd/bisync/operations.go
+++ b/cmd/bisync/operations.go
@@ -98,7 +98,10 @@ func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
if !opt.DryRun {
lockFile = b.basePath + ".lck"
if bilib.FileExists(lockFile) {
- return fmt.Errorf("prior lock file found: %s", lockFile)
+ errTip := Color(terminal.MagentaFg, "Tip: this indicates that another bisync run (of these same paths) either is still running or was interrupted before completion. \n")
+ errTip += Color(terminal.MagentaFg, "If you're SURE you want to override this safety feature, you can delete the lock file with the following command, then run bisync again: \n")
+ errTip += fmt.Sprintf(Color(terminal.HiRedFg, "rclone deletefile \"%s\""), lockFile)
+ return fmt.Errorf(Color(terminal.RedFg, "prior lock file found: %s \n")+errTip, Color(terminal.HiYellowFg, lockFile))
}
pidStr := []byte(strconv.Itoa(os.Getpid()))
@@ -222,7 +225,13 @@ func (b *bisyncRun) runLocked(octx context.Context) (err error) {
// On prior critical error abort, the prior listings are renamed to .lst-err to lock out further runs
b.critical = true
b.retryable = true
- return errors.New("cannot find prior Path1 or Path2 listings, likely due to critical error on prior run")
+ errTip := Color(terminal.MagentaFg, "Tip: here are the filenames we were looking for. Do they exist? \n")
+ errTip += fmt.Sprintf(Color(terminal.CyanFg, "Path1: %s\n"), Color(terminal.HiBlueFg, b.listing1))
+ errTip += fmt.Sprintf(Color(terminal.CyanFg, "Path2: %s\n"), Color(terminal.HiBlueFg, b.listing2))
+ errTip += Color(terminal.MagentaFg, "Try running this command to inspect the work dir: \n")
+ errTip += fmt.Sprintf(Color(terminal.HiCyanFg, "rclone lsl \"%s\""), b.workDir)
+
+ return errors.New("cannot find prior Path1 or Path2 listings, likely due to critical error on prior run \n" + errTip)
}
fs.Infof(nil, "Building Path1 and Path2 listings")
@@ -526,6 +535,9 @@ func (b *bisyncRun) checkAccess(checkFiles1, checkFiles2 bilib.Names) error {
numChecks1 := len(checkFiles1)
numChecks2 := len(checkFiles2)
if numChecks1 == 0 || numChecks1 != numChecks2 {
+ if numChecks1 == 0 && numChecks2 == 0 {
+ fs.Logf("--check-access", Color(terminal.RedFg, "Failed to find any files named %s\n More info: %s"), Color(terminal.CyanFg, opt.CheckFilename), Color(terminal.BlueFg, "https://rclone.org/bisync/#check-access"))
+ }
fs.Errorf(nil, "%s Path1 count %d, Path2 count %d - %s", prefix, numChecks1, numChecks2, opt.CheckFilename)
ok = false
}
diff --git a/cmd/bisync/testdata/test_check_access/golden/test.log b/cmd/bisync/testdata/test_check_access/golden/test.log
index 39d7452a7..2b8e6c982 100644
--- a/cmd/bisync/testdata/test_check_access/golden/test.log
+++ b/cmd/bisync/testdata/test_check_access/golden/test.log
@@ -83,7 +83,12 @@ Bisync error: bisync aborted
(19) : test 6. run again. should fail critical due to missing listings.
(20) : bisync check-access
INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
-ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+Tip: here are the filenames we were looking for. Do they exist?
+Path1: {workdir/}{session}.path1.lst
+Path2: {workdir/}{session}.path2.lst
+Try running this command to inspect the work dir:
+rclone lsl "{workdir}"
ERROR : Bisync aborted. Must run --resync to recover.
Bisync error: bisync aborted
(21) : move-listings missing-listings
diff --git a/cmd/bisync/testdata/test_check_sync/golden/test.log b/cmd/bisync/testdata/test_check_sync/golden/test.log
index f971b6d1d..edc5c221f 100644
--- a/cmd/bisync/testdata/test_check_sync/golden/test.log
+++ b/cmd/bisync/testdata/test_check_sync/golden/test.log
@@ -32,7 +32,12 @@ Bisync error: bisync aborted
(12) : test 4. run normal sync to check that it aborts
(13) : bisync
INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
-ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+Tip: here are the filenames we were looking for. Do they exist?
+Path1: {workdir/}{session}.path1.lst
+Path2: {workdir/}{session}.path2.lst
+Try running this command to inspect the work dir:
+rclone lsl "{workdir}"
ERROR : Bisync aborted. Must run --resync to recover.
Bisync error: bisync aborted
diff --git a/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log b/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log
index 4685d005e..2e099b9f6 100644
--- a/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log
+++ b/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log
@@ -24,7 +24,12 @@ Bisync error: bisync aborted
(08) : test 3. run without filters-file. should be blocked due to prior abort.
(09) : bisync
INFO : Synching Path1 "{path1/}" with Path2 "{path2/}"
-ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run
+Tip: here are the filenames we were looking for. Do they exist?
+Path1: {workdir/}{session}.path1.lst
+Path2: {workdir/}{session}.path2.lst
+Try running this command to inspect the work dir:
+rclone lsl "{workdir}"
ERROR : Bisync aborted. Must run --resync to recover.
Bisync error: bisync aborted