Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable auto clean of cache #21

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading