Call enterDir/leaveDir if a directory's child may be selected #3000
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.
This allows leaveDir to set metadata properly for directories
with descendants that are selected by an include filter, even
if the directory in question isn't selected by that filter.
For example, let's say you have the following file in your repo:
...and / and /home are owned by root, but /home/user and below are owned
by user.
If you run "restic restore -i /home/user/nested/data -t /tmp/restore $SNAPSHOT" as root,
/home/user/nested/ will currently be restored with root as the owner,
even though it's supposed to be owned by user.
This change makes sure that leaveDir is called to restore metadata to
nodes like /home/user/nested - enterDir is also called under the same
circumstances for purposes of symmetry.
This fixes GH #1402 and (I think) GH #2563
What does this PR change? What problem does it solve?
This PR changes directory traversal logic when restoring a snapshot, and it fixes a bug around restoration of metadata.
Was the change discussed in an issue or in the forum before?
This PR closes #1402 and closes #2563
Checklist
changelog/unreleased/
that describes the changes for our users (template here)gofmt
on the code in all commits