1
mirror of https://github.com/rclone/rclone synced 2025-01-09 11:46:24 +01:00

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.
This commit is contained in:
Nick Craig-Wood 2024-03-08 12:07:28 +00:00
parent cbcfb90d9a
commit 18e9d039ad

View File

@ -139,7 +139,12 @@ func Touch(ctx context.Context, f fs.Fs, remote string) error {
return err return err
} }
fs.Debugf(nil, "Touch time %v", t) 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 err != nil {
if errors.Is(err, fs.ErrorObjectNotFound) { if errors.Is(err, fs.ErrorObjectNotFound) {
// Touching non-existent path, possibly creating it as new file // Touching non-existent path, possibly creating it as new file