Skip to content
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

Repository: Remove Backend() method #4802

Merged
merged 17 commits into from May 18, 2024

Conversation

MichaelEischer
Copy link
Member

@MichaelEischer MichaelEischer commented May 10, 2024

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

This PR removes the Backend() method from the repository. Thereby it is no longer possible to directly manipulate repository data structures. The main consequence is that code that touches repository internal data structures, must now live within the repository package. It will also make it simpler in the future to get rid of the global repository interface as the interface is less nested.

To allow this refactor, the PR adds a RemoveUnpacked() method to the repository that currently allows deleting arbitrary files. This will change in a future PR, however, would require too much refactoring for now. In addition, the upgrade_repo_v2 migration and checker.checkPack have moved into the repository package.

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

The roadmap for 0.17 contains a refactor to limit modifications of unpacked files through the repository API. This PR is a prerequisite for getting there.

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.

Only handling one specific error is not particularly useful.
RemoveUnpacked will eventually block removal of all filetypes other than
snapshots. However, getting there requires a major refactor to provide
some components with privileged access.
The migration modifies repository internals and thus should live within
the repository package.
The migration will be removed after the next restic release anyways.
Thus, there's no need for a clean implementation.
This allows the Lock function to access the backend, even once the
Backend method is removed from the interface.
These will eventually be blocked as they do not delete Snapshots.
The cache cleanup pattern is also used in ListPack etc.
Copy link
Member Author

@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.

@MichaelEischer MichaelEischer merged commit 1dfe1b8 into restic:master May 18, 2024
13 checks passed
@MichaelEischer MichaelEischer deleted the backend-cleanups branch May 18, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant