Skip to content

File stays locked if OC\Files\View.rename() fails #7009

@korelstar

Description

@korelstar

Problem

As an app developer, I want to rename a file. Therefore, I call OC\Files\Node\Node.move(...) which calls OC\Files\View.rename(...). If the rename fails (e.g. due to an illegal file name), then an InvalidPathException is 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. by verifyPath(...).

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.

If you agree, I can provide a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions