-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Unlock files even if an exception occurs while renaming #7014
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
Conversation
aee43f4 to
9141e24
Compare
Codecov Report
@@ Coverage Diff @@
## master #7014 +/- ##
============================================
+ Coverage 50.61% 50.62% +<.01%
- Complexity 24297 24298 +1
============================================
Files 1577 1577
Lines 92922 92925 +3
Branches 1359 1359
============================================
+ Hits 47037 47039 +2
- Misses 45885 45886 +1
|
|
Finally! This has been so annoying for the past years. |
|
Can you please sign your commits? See https://github.com/nextcloud/server/blob/master/CONTRIBUTING.md#sign-your-work for more information. You can do this manually for now: |
|
@korelstar If this goes in to 13, could you please backport to 12 and 11 as well? |
Signed-off-by: Kristof Hamann <korelstar@users.noreply.github.com>
9141e24 to
c748240
Compare
|
@nickvergessen @enoch85 |
Generally speaking our rule on backports is that we only backport really critical issues (such as data loss) or cases where we experienced major issues at customer deployments. – To be honest, I'm a little bit reluctant to backport any changes to the file system. Even simple changes broke things in the past, so I'm better safe than sorry 😄 |
|
@icewind1991 What's your professional opinion here? :) |
@korelstar Please do :) |
|
@korelstar For the backport just create a branch based on stable12, cherry-pick the commit from here and then create a PR against stable12 over here on github. We will then review this one as well and merge it. Once you opened the PR you could also remove the "backport-request" label from this PR. Thanks |
Fixes #7009:
Problem
As an app developer, I want to rename a file. Therefore, I call
OC\Files\Node\Node.move(...)which callsOC\Files\View.rename(...). If the rename fails (e.g. due to an illegal file name), then anInvalidPathExceptionis thrown. The problem is, that the file is still locked, even if I catch the exception.Cause
The reason is that
OC\Files\View.rename(...)locks the old and new path, but it doesn't unlock them if an exception is thrown, e.g. byverifyPath(...).Solution
As a solution, I suggest to move the code of
OC\Files\View.rename(...)after locking into a try-catch-finally block in order to ensure that the locks are always freed.The diff looks big, but most oft the changes are just indentation.