Skip to content

Commit 7ed32f0

Browse files
committed
refactor
1 parent 9b421a8 commit 7ed32f0

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

cmd/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Supported storage systems: https://juicefs.com/docs/community/how_to_setup_objec
143143
Usage: "copy symlinks as symlinks",
144144
},
145145
&cli.Int64Flag{
146-
Name: "limits",
146+
Name: "limit",
147147
Usage: "limit the number of objects that will be processed",
148148
Value: -1,
149149
},

docs/en/reference/command_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ The order in which `--exclude` and `--include` are set will affect the result. E
564564
`--links, -l`<br />
565565
copy symlinks as symlinks (default: false)
566566

567-
` --limits value`<br />
567+
` --limit value`<br />
568568
limit the number of objects that will be processed (default: -1)
569569

570570
`--manager value`<br />

docs/zh_cn/reference/command_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ juicefs sync [command options] SRC DST
562562
`--links, -l`<br />
563563
将符号链接复制为符号链接 (默认: false)
564564

565-
` --limits value`<br />
565+
` --limit value`<br />
566566
限制将要处理的对象的数量 (默认: -1)
567567

568568
`--manager value`<br />

pkg/sync/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Config struct {
3535
Exclude []string
3636
Include []string
3737
Links bool
38-
Limits int64
38+
Limit int64
3939
Manager string
4040
Workers []string
4141
BWLimit int
@@ -65,7 +65,7 @@ func NewConfigFromCli(c *cli.Context) *Config {
6565
Exclude: c.StringSlice("exclude"),
6666
Include: c.StringSlice("include"),
6767
Links: c.Bool("links"),
68-
Limits: c.Int64("limits"),
68+
Limit: c.Int64("limit"),
6969
Workers: c.StringSlice("worker"),
7070
Manager: c.String("manager"),
7171
BWLimit: c.Int("bwlimit"),

pkg/sync/sync.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,11 @@ func deleteFromDst(tasks chan<- object.Object, dstobj object.Object, config *Con
589589
logger.Debug("Ignore deleting dst directory ", dstobj.Key())
590590
return false
591591
}
592-
if config.Limits != -1 {
593-
if config.Limits == 0 {
592+
if config.Limit != -1 {
593+
if config.Limit == 0 {
594594
return true
595595
}
596-
config.Limits--
596+
config.Limit--
597597
}
598598
tasks <- &withSize{dstobj, markDeleteDst}
599599
handled.IncrTotal(1)
@@ -637,11 +637,11 @@ func producer(tasks chan<- object.Object, src, dst object.ObjectStorage, config
637637
logger.Debug("Ignore directory ", obj.Key())
638638
continue
639639
}
640-
if config.Limits != -1 {
641-
if config.Limits == 0 {
640+
if config.Limit != -1 {
641+
if config.Limit == 0 {
642642
return
643643
}
644-
config.Limits--
644+
config.Limit--
645645
}
646646
handled.IncrTotal(1)
647647

pkg/sync/sync_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestSync(t *testing.T) {
100100
Perms: true,
101101
Dry: false,
102102
DeleteSrc: false,
103-
Limits: -1,
103+
Limit: -1,
104104
DeleteDst: false,
105105
Exclude: []string{"c*"},
106106
Include: []string{"a[1-9]", "a*"},
@@ -188,7 +188,7 @@ func TestSyncIncludeAndExclude(t *testing.T) {
188188
DeleteSrc: false,
189189
DeleteDst: false,
190190
Verbose: false,
191-
Limits: -1,
191+
Limit: -1,
192192
Quiet: true,
193193
Exclude: []string{"1"},
194194
}
@@ -357,7 +357,7 @@ func TestSyncLink(t *testing.T) {
357357
Perms: true,
358358
Links: true,
359359
Quiet: true,
360-
Limits: -1,
360+
Limit: -1,
361361
ForceUpdate: true,
362362
}); err != nil {
363363
t.Fatalf("sync: %s", err)
@@ -413,7 +413,7 @@ func TestSyncLinkWithOutFollow(t *testing.T) {
413413
Perms: true,
414414
Quiet: true,
415415
ForceUpdate: true,
416-
Limits: -1,
416+
Limit: -1,
417417
}); err != nil {
418418
t.Fatalf("sync: %s", err)
419419
}
@@ -447,7 +447,7 @@ func TestSingleLink(t *testing.T) {
447447
Perms: true,
448448
Links: true,
449449
Quiet: true,
450-
Limits: -1,
450+
Limit: -1,
451451
ForceUpdate: true,
452452
}); err != nil {
453453
t.Fatalf("sync: %s", err)
@@ -500,7 +500,7 @@ func TestLimits(t *testing.T) {
500500
Perms: true,
501501
}
502502
setConfig := func(config *Config, subC subConfig) {
503-
config.Limits = subC.limit
503+
config.Limit = subC.limit
504504
config.DeleteDst = subC.deleteDst
505505
}
506506

0 commit comments

Comments
 (0)