Skip to content

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

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.

Activity

  1. MorrisJobke commented on Oct 30, 2017

    @MorrisJobke
    Member

    @korelstar: Makes sense - maybe @icewind1991 has some opinion on this, but I would say, that a PR is fine and good for a discussion.

  2. icewind1991 commented on Oct 30, 2017

    @icewind1991
    Member

    Sounds good

  3. korelstar commented on Oct 30, 2017

    @korelstar
    MemberAuthor

    Please see #7014 for the PR.

  4. added this to the Nextcloud 13 milestone on Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions