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

Debug directory creation and removal - fixes #1192

Nick Craig-Woodf3c7e1a9dde7
diff --git a/fs/operations.go b/fs/operations.go
index 8129d9726..a0d39e09c 100644
--- a/fs/operations.go
+++ b/fs/operations.go
@@ -1061,12 +1061,21 @@ func ListDir(f Fs, w io.Writer) error {
})
}
+// logDirName returns an object for the logger
+func logDirName(f Fs, dir string) interface{} {
+ if dir != "" {
+ return dir
+ }
+ return f
+}
+
// Mkdir makes a destination directory or container
func Mkdir(f Fs, dir string) error {
if Config.DryRun {
- Logf(f, "Not making directory as dry run is set")
+ Logf(logDirName(f, dir), "Not making directory as dry run is set")
return nil
}
+ Debugf(logDirName(f, dir), "Making directory")
err := f.Mkdir(dir)
if err != nil {
Stats.Error()
@@ -1079,13 +1088,10 @@ func Mkdir(f Fs, dir string) error {
// count errors but may return one.
func TryRmdir(f Fs, dir string) error {
if Config.DryRun {
- if dir != "" {
- Logf(dir, "Not deleting as dry run is set")
- } else {
- Logf(f, "Not deleting as dry run is set")
- }
+ Logf(logDirName(f, dir), "Not deleting as dry run is set")
return nil
}
+ Debugf(logDirName(f, dir), "Removing directory")
return f.Rmdir(dir)
}