bisync: provide more info in critical error msgs

This commit is contained in:
nielash 2023-11-11 00:34:41 -05:00
parent 44637dcd7f
commit 4d5d6ee61b
5 changed files with 33 additions and 5 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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