From 2b7994e73937192cf4eb9affd02ee727272e947d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 29 Sep 2020 17:03:25 +0100 Subject: [PATCH] operations: add logs when need to upload files to set mod times #1505 --- fs/operations/operations.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index da2813827..b899e755d 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -151,6 +151,15 @@ func defaultEqualOpt() equalOpt { } } +var modTimeUploadOnce sync.Once + +// emit a log if we are about to upload a file to set its modification time +func logModTimeUpload(dst fs.Object) { + modTimeUploadOnce.Do(func() { + fs.Logf(dst.Fs(), "Forced to upload files to set modification times on this backend.") + }) +} + func equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object, opt equalOpt) bool { if sizeDiffers(src, dst) { fs.Debugf(src, "Sizes differ (src %d vs dst %d)", src.Size(), dst.Size()) @@ -223,10 +232,12 @@ func equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object, opt equalOpt) // Update the mtime of the dst object here err := dst.SetModTime(ctx, srcModTime) if err == fs.ErrorCantSetModTime { - fs.Debugf(dst, "src and dst identical but can't set mod time without re-uploading") + logModTimeUpload(dst) + fs.Infof(dst, "src and dst identical but can't set mod time without re-uploading") return false } else if err == fs.ErrorCantSetModTimeWithoutDelete { - fs.Debugf(dst, "src and dst identical but can't set mod time without deleting and re-uploading") + logModTimeUpload(dst) + fs.Infof(dst, "src and dst identical but can't set mod time without deleting and re-uploading") // Remove the file if BackupDir isn't set. If BackupDir is set we would rather have the old file // put in the BackupDir than deleted which is what will happen if we don't delete it. if fs.Config.BackupDir == "" {