Open cofinalsubnets opened 1 year ago
Looks good to me.
Could you please also update the README and mention this configuration option + add one to the an example.
Could you please also run the reformatter gofumpt -w -l .
to fix 2 following issues:
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: