b2: add --max-age option to cleanup-hidden command#9446
Open
pkolbus wants to merge 2 commits into
Open
Conversation
c48b6ac to
ff503f3
Compare
Add a max-age option to the cleanup-hidden command; this deletes files hidden more than --max-age ago. For backward compatibility, the default is 0 (delete all hidden files).
ff503f3 to
83e9066
Compare
ncw
reviewed
May 24, 2026
ncw
requested changes
May 25, 2026
ncw
left a comment
Member
There was a problem hiding this comment.
Hi.
Thanks for doing this.
I think there are a couple of correctness issues we need to address - see inline.
Thank you :-)
|
|
||
| func (f *Fs) cleanupHiddenCommand(ctx context.Context, name string, arg []string, opt map[string]string) (out any, err error) { | ||
| return nil, f.cleanUp(ctx, true, false, 0) | ||
| maxAge := defaultMaxAge |
Member
There was a problem hiding this comment.
This changes the default from unset to defaultMaxAge which is a behaviour change.
I think you want maxAge := time.Duration(0) here
| // Check current version of the file | ||
| if deleteHidden && object.Action == "hide" { | ||
| fs.Debugf(remote, "Deleting current version (id %q) as it is a hide marker", object.ID) | ||
| if deleteHidden && object.Action == "hide" && isUploadStale(object.UploadTimestamp) { |
Member
There was a problem hiding this comment.
This is changing the behaviour of the Purge and Cleanup methods isn't it?
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.
What is the purpose of this change?
Allow preserving recently hidden files during a
cleanup-hiddenoperation, while deleting files that have been hidden longer. This allows (for example):The implementation takes advantage of code shared with
cleanup, which already has amax-ageoption. However in this case the default is 0 for backward compatibility.Note: Automated tests are not added, as any would be fragile.
b2_internal_test.goisn't architected for precise control of timing, only that file versions are created a couple of seconds apart. The implementation of b2'sbackend cleanupalso does not have max-age tests. That said, I have tested manually with-vv; the log messages and file version listings confirm that this works.Was the change discussed in an issue or in the forum before?
No
Checklist