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
restic forget --keep-* options will interpret -1 as "forever" #4234
restic forget --keep-* options will interpret -1 as "forever" #4234
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.
Thanks for working on this issue! The code looks solid except for the comments below. Regarding --keep-within-*
, I think restic should just return an error if any of them contains a negative duration. I don't see a use case in which that would make sense.
Thanks for the feedback, @MichaelEischer! I'll update the PR with the recommended changes. 👍 |
Tests in cmd_forget_test.go need the same convenience function that was implemented in snapshot_policy_test.go. Function parseDuration(...) was moved to testing.go and renamed to ParseDurationOrPanic(...).
- Convert policy sum calculation to function and move to tests. - Remove parseDuration(...) and use ParseDurationOrPanic(...) instead.
@MichaelEischer Alrighty, made the changes. This resulted in minor refactoring: had to move (and slightly change) a helper function from |
Actually, I'll update this PR further with changes to |
Ok, updated PR. Options such as
|
@MichaelEischer Any feedback on the updated PR? Happy to update the docs if that's all that's misisng at this point. |
@thndrbrrr Sorry for the late reply, I've been far too busy during the last few weeks. Thanks for the changes, the code now looks good to me. The only two remaining todos are a short changelog entry (see template ) and a similar note in the documentation. |
@MichaelEischer Docs and changelog updated. I updated the usage text as well, let me know if you're not happy with the wording:
|
No worries, I know how that feels ... 😆 |
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.
I only have one small remaining nitpick. Besides that LGTM.
What does this PR change? What problem does it solve?
restic forget
will interpret-1
as "forever" when used with--keep-*
options. Using a value less than-1
will result in an error.Note: This PR does not change the existing behaviour of--keep-within*
options until it's decided how durations containing negative values should be handled (see my comment in #2565).--keep-within*
options containing negative values are considered invalid.Documentation has not been updated (waiting on confirmation for this PR to go ahead).
Was the change previously discussed in an issue or on the forum?
Closes #2565
(if--keep-within-*
options could be considered a different issue)Checklist
changelog/unreleased/
that describes the changes for our users (see template).gofmt
on the code in all commits.