mirror of
https://github.com/rclone/rclone.git
synced 2025-12-12 06:24:14 +01:00
touch: make touch obey --transfers
Before this change, when executed on a directory, rclone would only touch files sequentially. This change makes rclone touch --transfers files at once. Fixes #8402
This commit is contained in:
@@ -2140,20 +2140,28 @@ func SetTierFile(ctx context.Context, o fs.Object, tier string) 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 {
|
||||
ci := fs.GetConfig(ctx)
|
||||
g, gCtx := errgroup.WithContext(ctx)
|
||||
g.SetLimit(ci.Transfers)
|
||||
err := 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())
|
||||
err := o.SetModTime(ctx, t)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to touch: %w", err)
|
||||
err = fs.CountError(ctx, err)
|
||||
fs.Errorf(o, "%v", err)
|
||||
}
|
||||
g.Go(func() error {
|
||||
fs.Debugf(f, "Touching %q", o.Remote())
|
||||
err := o.SetModTime(gCtx, t)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to touch: %w", err)
|
||||
err = fs.CountError(gCtx, err)
|
||||
fs.Errorf(o, "%v", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
})
|
||||
return nil
|
||||
})
|
||||
_ = g.Wait()
|
||||
return err
|
||||
}
|
||||
|
||||
// ListFormat defines files information print format
|
||||
|
||||
Reference in New Issue
Block a user