Skip to content

Prevent version app operations when file is locked #17245

Closed

Description

@PVince81

Steps to reproduce

  1. Enable transactional locking
  2. Create a file "test.txt"
  3. Edit "test.txt" and save multiple times to create versions
  4. A sleep(30); here to delay rename operation:
    if ($internalPath1 === '' and $mount1 instanceof MoveableMount) {
  5. In a separate tab, rename "test.txt" to "renamed.txt" (this should take a while)
  6. In the first tab, during renaming, try downloading a version

Expected result

File is locked, cannot download (or restore) version.

Actual result

It is still possible to download or restore a version

Versions

ownCloud 8.1 git master b88a0e7

File actions from apps like versions need to also lock the file.

@icewind1991 @jnfrmarks @DeepDiver1975 @schiesbn

Activity

  1. added this to the milestone on Jun 29, 2015
  2. PVince81 commented on Jun 29, 2015

    @PVince81
    ContributorAuthor

    Tentatively setting to 8.1, but not sure if enough time to fix it.

  3. modified the milestones: , on Jul 1, 2015
  4. PVince81 commented on Jul 1, 2015

    @PVince81
    ContributorAuthor

    @cmonteroluque @karlitschek @DeepDiver1975 moving to 8.1.1.
    Needed to make locking more watertight.

  5. schiessle commented on Jul 1, 2015

    @schiessle
    Contributor

    I think it is probably OK that the download of a version works. The version is a different file then the original one. So why should we block the version if the original file gets manipulated.

    I agree that restore shouldn't work. But what is the problem here? File versions always uses a view, so the same locking logic should be applied as for every other file? If you try to move a version to the original file and the original file is already locked the restore operation should be blocked.

  6. PVince81 commented on Jul 1, 2015

    @PVince81
    ContributorAuthor

    Downloading a version might work yes, thanks to the background job expiration the old "to be expired" version might still exist at the time of the download, even though the pending upload would expire it.

    Even if the versions app uses the view, the restore operations aren't done within a view operation. Also if the view is working on the version file instead of the original one, it will lock the version file instead of the original file.
    I think like for encryption and others we need to explicitly set a lock on the original file before we start the sub-operations for a file restore, and unlock at the end of it. (to make it a real transaction)

  7. PVince81 commented on Jul 1, 2015

    @PVince81
    ContributorAuthor

    Without transaction, have a look at https://github.com/owncloud/core/blob/master/apps/files_versions/lib/storage.php#L294 and for every file operation, ask yourself what could go wrong if someone else moved/deleted/overwrote the original file in-between.

  8. PVince81 commented on Jul 1, 2015

    @PVince81
    ContributorAuthor

    Same question actually for getVersions(): https://github.com/owncloud/core/blob/master/apps/files_versions/lib/storage.php#L349

    If someone is currently moving the file, there is another process that will move the versions in process B while process A is trying to retrieve its list. We should at least set a shared lock on the original file here. The move operation would then set an exclusive lock on the file.

  9. modified the milestones: , on Jul 16, 2015
  10. locked as resolved and limited conversation to collaborators on Aug 8, 2019
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