touch: fix issue where directory is created instead of file

Detected on ftp, sftp and Dropbox backends.

Fixes #5952
This commit is contained in:
albertony
2022-01-27 19:46:53 +01:00
parent bd6d36b3f6
commit 07f53aebdc
4 changed files with 53 additions and 19 deletions

View File

@@ -1929,9 +1929,9 @@ func SetTier(ctx context.Context, fsrc fs.Fs, tier string) error {
})
}
// TouchDir touches every file in f with time t
func TouchDir(ctx context.Context, f fs.Fs, t time.Time, recursive bool) error {
return walk.ListR(ctx, f, "", false, ConfigMaxDepth(ctx, recursive), walk.ListObjects, func(entries fs.DirEntries) error {
// TouchDir touches every file in directory with time t
func TouchDir(ctx context.Context, f fs.Fs, remote string, t time.Time, recursive bool) error {
return walk.ListR(ctx, f, remote, false, ConfigMaxDepth(ctx, recursive), walk.ListObjects, func(entries fs.DirEntries) error {
entries.ForObject(func(o fs.Object) {
if !SkipDestructive(ctx, o, "touch") {
fs.Debugf(f, "Touching %q", o.Remote())