Skip to content

Commit

Permalink
fix(cli): fixed 'cache set' CLI regression due to kingpin change
Browse files Browse the repository at this point in the history
This was caused by a default `-1ns` which is no longer supported
in latest Kingpin.

The effect was that `kopia cache set` without
`--max-list-cache-duration` would fail. Unforutnately test was passing
that flag so it was missed.

This was likely caused by alecthomas/kingpin#329
  • Loading branch information
jkowalski committed Jul 10, 2022
1 parent 8515d05 commit 8a89afd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/command_cache_set.go
Expand Up @@ -29,14 +29,15 @@ func (c *commandCacheSetParams) setup(svc appServices, parent commandParent) {
c.contentMinSweepAge = -1
c.metadataMinSweepAge = -1
c.indexMinSweepAge = -1
c.maxListCacheDuration = -1

cmd.Flag("cache-directory", "Directory where to store cache files").StringVar(&c.directory)
cmd.Flag("content-cache-size-mb", "Size of local content cache").PlaceHolder("MB").Default("-1").Int64Var(&c.contentCacheSizeMB)
cmd.Flag("content-min-sweep-age", "Minimal age of content cache item to be subject to sweeping").DurationVar(&c.contentMinSweepAge)
cmd.Flag("metadata-cache-size-mb", "Size of local metadata cache").PlaceHolder("MB").Default("-1").Int64Var(&c.maxMetadataCacheSizeMB)
cmd.Flag("metadata-min-sweep-age", "Minimal age of metadata cache item to be subject to sweeping").DurationVar(&c.metadataMinSweepAge)
cmd.Flag("index-min-sweep-age", "Minimal age of index cache item to be subject to sweeping").DurationVar(&c.indexMinSweepAge)
cmd.Flag("max-list-cache-duration", "Duration of index cache").Default("-1ns").DurationVar(&c.maxListCacheDuration)
cmd.Flag("max-list-cache-duration", "Duration of index cache").DurationVar(&c.maxListCacheDuration)
cmd.Action(svc.repositoryWriterAction(c.run))
c.svc = svc
}
Expand Down
8 changes: 7 additions & 1 deletion cli/command_cache_set_test.go
Expand Up @@ -19,12 +19,18 @@ func TestCacheSet(t *testing.T) {
env.RunAndExpectFailure(t, "cache", "set")

ncd := testutil.TempDirectory(t)

env.RunAndExpectSuccess(t,
"cache", "set",
"--cache-directory", ncd,
"--max-list-cache-duration=55s",
)

env.RunAndExpectSuccess(t,
"cache", "set",
"--cache-directory", ncd,
"--content-cache-size-mb=33",
"--metadata-cache-size-mb=44",
"--max-list-cache-duration=55s",
)

out := env.RunAndExpectSuccess(t, "cache", "info")
Expand Down

0 comments on commit 8a89afd

Please sign in to comment.