Skip to content

Commit

Permalink
enable auto clean of cache
Browse files Browse the repository at this point in the history
Automatically clean cache not used in last 30 days

Signed-off-by: Yves Brissaud <[email protected]>
  • Loading branch information
eunomie committed Oct 16, 2024
1 parent 796118d commit 436f060
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/commands/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
Short: "Docker Run, better",
RunE: func(cmd *cobra.Command, args []string) error {
var (
src string
action string
lc = runkit.GetLocalConfig()
cache = runkit.NewLocalCache(dockerCli)
src string
action string
lc = runkit.GetLocalConfig()
localCache = runkit.NewLocalCache(dockerCli)
)

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

_ = localCache.EraseNotAccessedInLast30Days()

var (
err error
rk *runkit.RunKit
Expand All @@ -89,14 +91,14 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
Type(spinner.Globe).
Title(" Fetching runx details...").
Action(func() {
rk, err = runkit.Get(cmd.Context(), cache, src)
rk, err = runkit.Get(cmd.Context(), localCache, src)
if err != nil {
_, _ = fmt.Fprintln(dockerCli.Err(), err)
os.Exit(1)
}
}).Run()
} else {
rk, err = runkit.Get(cmd.Context(), cache, src)
rk, err = runkit.Get(cmd.Context(), localCache, src)
}
if err != nil {
return err
Expand Down

0 comments on commit 436f060

Please sign in to comment.