-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add per-repo file purge times #74
base: master
Are you sure you want to change the base?
Conversation
Adds a per-repo `purge_files_after` configuration option that overrides the global setting if present.
e25ea18
to
29a7d69
Compare
Looks good to me. Could you please also update the README and mention this configuration option + add one to the an example. |
@@ -9,6 +9,19 @@ import ( | |||
"github.com/google/go-cmp/cmp/cmpopts" | |||
) | |||
|
|||
func (r *Repo) Equal(x interface{}) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Equal function introduction seems unrelated to perrepo purge option. It makes sense to move it to a separate commit (but keep it in this PR).
Could you please also run the reformatter diff --git a/config_test.go b/config_test.go
index abd377d..e6ae55c 100644
--- a/config_test.go
+++ b/config_test.go
@@ -153,14 +153,14 @@ repos:
CacheDir: `/tmp`,
Port: 9129,
Repos: map[string]*Repo{
- "archlinux": &Repo{
+ "archlinux": {
URL: "http://mirrors.kernel.org/archlinux",
},
- "anotherlinux": &Repo{
+ "anotherlinux": {
URL: "http://dev.null",
PurgeFilesAfter: &zero,
},
- "yetanotherlinux": &Repo{
+ "yetanotherlinux": {
URL: "http://dev.zero",
PurgeFilesAfter: &oneHundredThousand,
},
diff --git a/purge.go b/purge.go
index db74a2d..74bf4a4 100644
--- a/purge.go
+++ b/purge.go
@@ -18,7 +18,7 @@ func (r *Repo) purgeSeconds() int {
func setupPurgeStaleFilesRoutine() *time.Ticker {
ticker := time.NewTicker(time.Duration(24) * time.Hour) // purge files once a day
go func() {
- for _ = range ticker.C {
+ for range ticker.C {
for repoName, repo := range config.Repos {
dir := filepath.Join(config.CacheDir, "pkgs", repoName)
purgeStaleFiles(dir, repo.purgeSeconds()) |
I am thinking of a new release for pacoloco to bring the recent fixes to users. Hi @GW000, if you plan to work on this PR in the near future then I would prefer to wait with the release a bit until the PR is merged. |
ping @cofinalsubnets, are you still interested in moving this PR forward? |
Hi. This PR adds a per-repository
purge_files_after
configuration option that overrides the global setting if present.As an example of how this is useful, my use case is that i want to use pacoloco to proxy the Arch Linux Archive. Since the archive by definition doesn't get package updates, i'm not concerned about the local cache growing too large; on the contrary, if i'm downloading a specific old version of something it's probably for some special reason, so i'd like to cache it indefinitely. But i'd also like to purge normal packages after a reasonable time. So now i can write this: