-
Notifications
You must be signed in to change notification settings - Fork 76
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
Fix directory rename hiding files from lower branches #152
Conversation
branch_contains_path() already does all the same checks we need to do here.
hi @Tuupertunut ! thank you very much for your contribution! i will take a look at this some time next week. anyway, some tests seem to be failing (see below) - can you look into it meanwhile? thanks! |
Yep, that's the case where cow is not enabled. Directory renaming heavily uses cow-copying so I didn't consider that it sometimes might need to work without cow enabled and I'm still not exactly sure how it should behave. I'll figure something out. |
Fixed the case with cow disabled by introducing a similar shortcut in the recursive cow-copy function as in the non-recursive one. Now all the tests pass. However I'm not sure the original shortcut code was working as intended and there was probably a bug already in the non-recursive function too: Rename fails when we have cow enabled, two read-write branches and we rename a file from the lower branch to a name already existing in upper branch. I'm not sure how unionfs is supposed to behave when cow is enabled but there are multiple read-write branches. It's not necessary to fix this right now but just something I discovered. |
thanks for the updates! i've quick-reviewed the code and it looks reasonable. i especially like the explanatory comments - great work! |
Those assertions are all |
yes, you are correct! i knew i must have overlooked something. ;-) ...so i've "fixed" the other checks and added a comment. other than that, i've merged your branch without changes. thanks again for your contribution! |
Fixes #91
This PR fixes the old issue #91 with directory rename. Previously after renaming a directory, only the contents of the highest branch were cow-copied up to the read-write branch, hiding all content the directory had in lower branches. In this PR a new function is introduced that can do a cow-copy recursively for a directory tree in every branch. Now if a file is renamed and it's a non-directory, we do a normal cow-copy, but for directories we do this recursive cow-copy instead. Everything should now work as expected from a proper directory rename.
Doing a cow-copy recursively for a whole directory is significantly more complex that for a single file:
Caveat: directory renaming is now much slower than before. That's the price of it working correctly.