-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Honor RESTIC_CACHE_DIR environment variable #3474
Conversation
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.
When placing the temporary check directories inside the regular restic cache directory, then no there's no guarantee that a cleanup of these directories will occur.
The problem is that the current cache cleanup mechanism explicitly ignores all directories which don't look like a repository id. Changing that would require a change in the following location or somewhere nearby:
restic/internal/cache/cache.go
Line 174 in 553ea36
func validCacheDirName(s string) bool { |
@MichaelEischer Thank you for your quick feedback and guidance. I have updated the pull request. If
The temp directory What should be the behaviour of Best regards, |
My reference to
I don't think that there's a reason to not just delete the whole |
@kitone Did you make any progress on this PR? |
Fix restic#3382: restic check doesn't obey the RESTIC_CACHE_DIR environment variable
f03f5a6
to
ae71f75
Compare
@MichaelEischer: Sorry for the delay, I was busy with work and forget to commit my change. So, the previous behaviour is now respected, we only change the cache directory if --cache-dir is setup or RESTIC_CACHE_DIR. For feedbacks, I added another commit that change the behaviour of cleanup = func() {
err := fs.RemoveAll(tempdir)
if err != nil {
Warnf("error removing temporary cache directory: %v\n", err)
}
} Changing
For now, Thanks for the feedbacks Best regards, |
I'm not sure I understand. Which caches would cleanup remove which it shouldn't have? I'd still prefer to just extend the cache name regexp and maybe filter the check caches from the output. That would also have the benefit of allowing automatic cleanups by other restic commands using
The code currently deletes every check cache it encounters even if it was created recently. That way it could actually delete a cache currently used by running check operation. Is there are reason not to use the same "x days old" logic as for normal cache directories? |
Because there is no guarantee that a cleanup of these directories will occur after the "restic check", we extend the behavior to detect and manage these specific cache directories and allow their cleanup too.
ae71f75
to
0425a30
Compare
I'm really sorry, I didn't fully understand the cache cleaning behavior, I just re-read the code and do some test and indeed this behavior is the correct one. I have updated the pr. I chose to display all the caches, in order to allow the user to have the information and thus choose if he should run a cleanup. Maybe we can filter the name to have a more explicit listing ?
by
or
Thanks again for your feedbacks, |
I like that variant. The number after restic/cmd/restic/cmd_cache.go Line 144 in 6c84ea1
It should be sufficient to not shorten the repo ID when it starts with |
…it in the case of the restic check
Change added in the last commit. Best regards, |
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.
LGTM. Thanks!
What does this PR change? What problem does it solve?
CacheDir option doesn't honor the
RESTIC_CACHE_DIR
environment variable by default, this is done by default now.This avoid checking for
gopts.CacheDir
andRESTIC_CACHE_DIR
environment variable.Was the change previously discussed in an issue or on the forum?
Fix #3382: restic check doesn't obey the RESTIC_CACHE_DIR environment variable
Checklist
changelog/unreleased/
that describes the changes for our users (see template).gofmt
on the code in all commits.