Add per-repo file purge times - #74
Open
cofinalsubnets wants to merge 1 commit into
Open
Conversation
Adds a per-repo `purge_files_after` configuration option that overrides the global setting if present.
cofinalsubnets
force-pushed
the
purge-per-repo
branch
from
March 21, 2023 05:04
e25ea18 to
29a7d69
Compare
Owner
|
Looks good to me. Could you please also update the README and mention this configuration option + add one to the an example. |
anatol
reviewed
Mar 22, 2023
| "github.com/google/go-cmp/cmp/cmpopts" | ||
| ) | ||
|
|
||
| func (r *Repo) Equal(x interface{}) bool { |
Owner
There was a problem hiding this comment.
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).
Owner
|
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()) |
Owner
|
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. |
Owner
|
ping @cofinalsubnets, are you still interested in moving this PR forward? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi. This PR adds a per-repository
purge_files_afterconfiguration 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: