From 18e9d039addec04ec2a8b312e9dbedff1b69f7a1 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 8 Mar 2024 12:07:28 +0000 Subject: [PATCH] touch: fix using -R on certain backends On backends which return a valid object for "" with NewObject then touch was going wrong as it thought it was passed an object. This should not happen normally but s3 can be configured with --s3-no-head where it is happy to believe that all objects exist. --- cmd/touch/touch.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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