fs/march: improve errors when root source/destination doesn't exist

See: https://forum.rclone.org/t/rclone-attempts-to-read-files-in-the-destination-directory-when-the-source-doesnt-exist/23412
This commit is contained in:
Nick Craig-Wood 2021-04-10 09:29:21 +01:00
parent 04308dcaa1
commit 1773717a47

View File

@ -404,14 +404,22 @@ func (m *March) processJob(job listDirJob) ([]listDirJob, error) {
// Wait for listings to complete and report errors // Wait for listings to complete and report errors
wg.Wait() wg.Wait()
if srcListErr != nil { if srcListErr != nil {
fs.Errorf(job.srcRemote, "error reading source directory: %v", srcListErr) if job.srcRemote != "" {
fs.Errorf(job.srcRemote, "error reading source directory: %v", srcListErr)
} else {
fs.Errorf(m.Fsrc, "error reading source root directory: %v", srcListErr)
}
srcListErr = fs.CountError(srcListErr) srcListErr = fs.CountError(srcListErr)
return nil, srcListErr return nil, srcListErr
} }
if dstListErr == fs.ErrorDirNotFound { if dstListErr == fs.ErrorDirNotFound {
// Copy the stuff anyway // Copy the stuff anyway
} else if dstListErr != nil { } else if dstListErr != nil {
fs.Errorf(job.dstRemote, "error reading destination directory: %v", dstListErr) if job.dstRemote != "" {
fs.Errorf(job.dstRemote, "error reading destination directory: %v", dstListErr)
} else {
fs.Errorf(m.Fdst, "error reading destination root directory: %v", dstListErr)
}
dstListErr = fs.CountError(dstListErr) dstListErr = fs.CountError(dstListErr)
return nil, dstListErr return nil, dstListErr
} }