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

touch: fix using -R on certain backends

Nick Craig-Wood18e9d039adde
diff --git a/cmd/touch/touch.go b/cmd/touch/touch.go
index e86aba555..4991e7d1f 100644
--- a/cmd/touch/touch.go
+++ b/cmd/touch/touch.go
@@ -139,7 +139,12 @@ func Touch(ctx context.Context, f fs.Fs, remote string) error {
return err
}
fs.Debugf(nil, "Touch time %v", t)
- file, err := f.NewObject(ctx, remote)
+ var file fs.Object
+ if remote == "" {
+ err = fs.ErrorIsDir
+ } else {
+ file, err = f.NewObject(ctx, remote)
+ }
if err != nil {
if errors.Is(err, fs.ErrorObjectNotFound) {
// Touching non-existent path, possibly creating it as new file