From 436f060970fdc461ce8f5dfa080daf44660a7e5d Mon Sep 17 00:00:00 2001 From: Yves Brissaud Date: Wed, 16 Oct 2024 12:43:10 +0200 Subject: [PATCH] enable auto clean of cache Automatically clean cache not used in last 30 days Signed-off-by: Yves Brissaud --- internal/commands/root/root.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/commands/root/root.go b/internal/commands/root/root.go index b1f62a1..c9e4c73 100644 --- a/internal/commands/root/root.go +++ b/internal/commands/root/root.go @@ -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) { @@ -79,6 +79,8 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command { return cmd.Help() } + _ = localCache.EraseNotAccessedInLast30Days() + var ( err error rk *runkit.RunKit @@ -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