mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
touch: add support for touching files in directory, with options for recursive, filtering and dry-run/interactive
Fixes #5301
This commit is contained in:
@@ -1906,6 +1906,23 @@ 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 {
|
||||
entries.ForObject(func(o fs.Object) {
|
||||
if !SkipDestructive(ctx, o, "touch") {
|
||||
fs.Debugf(f, "Touching %q", o.Remote())
|
||||
err := o.SetModTime(ctx, t)
|
||||
if err != nil {
|
||||
err = fs.CountError(err)
|
||||
fs.Errorf(o, "Failed to touch %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// ListFormat defines files information print format
|
||||
type ListFormat struct {
|
||||
separator string
|
||||
|
||||
Reference in New Issue
Block a user