Uh oh!
There was an error while loading. Please reload this page.
Unlock files even if an exception occurs while renaming - #7014
Conversation
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
|
enoch85
commented
Oct 30, 2017
Finally! This has been so annoying for the past years. |
nickvergessen
commented
Nov 1, 2017
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: |
enoch85
commented
Nov 2, 2017
@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>
korelstar
commented
Nov 4, 2017
@nickvergessen @enoch85 |
LukasReschke
commented
Nov 7, 2017
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 😄 |
LukasReschke
commented
Nov 7, 2017
@icewind1991 What's your professional opinion here? :) |
enoch85
commented
Nov 8, 2017
@korelstar Please do :) |
MorrisJobke
commented
Nov 9, 2017
@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.