Skip to content

cache: clear snapshot files from cache during load index#4981

Merged
MichaelEischer merged 8 commits intorestic:masterfrom
konidev20:fix-gh-4934-cleanup-removed-snaphots-from-cache
Aug 16, 2024
Merged

cache: clear snapshot files from cache during load index#4981
MichaelEischer merged 8 commits intorestic:masterfrom
konidev20:fix-gh-4934-cleanup-removed-snaphots-from-cache

Conversation

@konidev20
Copy link
Copy Markdown
Contributor

@konidev20 konidev20 commented Aug 4, 2024

What does this PR change? What problem does it solve?

clear snapshot files from cache during repository preparation.

Was the change previously discussed in an issue or on the forum?

There is a function in repository.go called prepareCache() which is used to clean up old index and pack files from the local cache. This method is called during LoadIndex.

Closes #4934

Checklist

  • I have read the contribution guidelines.
  • I have enabled maintainer edits.
  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I have run gofmt on the code in all commits.
  • All commit messages are formatted in the same style as the other commits in the repo.
  • I'm done! This pull request is ready for review.

@konidev20 konidev20 marked this pull request as draft August 4, 2024 18:50
Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to introduce an extra List call to backends just to clean up old snapshots.

@konidev20 konidev20 closed this Aug 10, 2024
@konidev20 konidev20 force-pushed the fix-gh-4934-cleanup-removed-snaphots-from-cache branch from 8ebfd58 to a48baf6 Compare August 10, 2024 19:20
@konidev20 konidev20 reopened this Aug 10, 2024
Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks fine in general, I just have a few small remarks on it. Other than that only a test and changelog entry are missing.

@konidev20 konidev20 marked this pull request as ready for review August 11, 2024 11:16
* removes files which are no longer in the repository, including index files, snapshot files and pack files from the cache.

cache: fix ids set initialisation with NewIDSet()
* remove the prepareCache method from the Repository
* changed the signature of the SetIndex function to no longer return an error
@konidev20 konidev20 force-pushed the fix-gh-4934-cleanup-removed-snaphots-from-cache branch from 8c72054 to 5fd984b Compare August 11, 2024 18:11
Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@MichaelEischer MichaelEischer added this pull request to the merge queue Aug 16, 2024
Merged via the queue into restic:master with commit 5cca6e6 Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup removed snapshots from cache

2 participants