Skip to content

Commit 4a17313

Browse files
authored
Merge pull request #21 from eunomie/auto-cache-prune
enable auto clean of cache
2 parents 796118d + 436f060 commit 4a17313

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

internal/commands/root/root.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
4545
Short: "Docker Run, better",
4646
RunE: func(cmd *cobra.Command, args []string) error {
4747
var (
48-
src string
49-
action string
50-
lc = runkit.GetLocalConfig()
51-
cache = runkit.NewLocalCache(dockerCli)
48+
src string
49+
action string
50+
lc = runkit.GetLocalConfig()
51+
localCache = runkit.NewLocalCache(dockerCli)
5252
)
5353

5454
switch len(args) {
@@ -79,6 +79,8 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
7979
return cmd.Help()
8080
}
8181

82+
_ = localCache.EraseNotAccessedInLast30Days()
83+
8284
var (
8385
err error
8486
rk *runkit.RunKit
@@ -89,14 +91,14 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
8991
Type(spinner.Globe).
9092
Title(" Fetching runx details...").
9193
Action(func() {
92-
rk, err = runkit.Get(cmd.Context(), cache, src)
94+
rk, err = runkit.Get(cmd.Context(), localCache, src)
9395
if err != nil {
9496
_, _ = fmt.Fprintln(dockerCli.Err(), err)
9597
os.Exit(1)
9698
}
9799
}).Run()
98100
} else {
99-
rk, err = runkit.Get(cmd.Context(), cache, src)
101+
rk, err = runkit.Get(cmd.Context(), localCache, src)
100102
}
101103
if err != nil {
102104
return err

0 commit comments

Comments
 (0)