nextcloud / files_lock

GNU Affero General Public License v3.0
25 stars 8 forks source link

Old versions can not be restored from the sidebar because file is locked #123

Closed max-nextcloud closed 1 year ago

max-nextcloud commented 1 year ago

How to reproduce:

The server responds with a 500 with this content

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>OCP\Lock\ManuallyLockedException</s:exception>
  <s:message>"files/AA.mine/test text/restore file version with lock.md" is locked, existing lock on file: files_lock/bd8abcbd-a01a-40c5-8332-b9c2e5c42cd2</s:message>
</d:error>
Trace from the server: ```yaml { app: webdav, method: MOVE, url: /remote.php/dav/versions//16523/1838744392, message: "files/filename.docx" is locked, existing lock on file: files_lock/15551a66-c88c-49ea-8c3c-e85585df40a3, exception: { Exception: OCP\Lock\ManuallyLockedException Message: "files/filename.docx" is locked, existing lock on file: files_lock/15551a66-c88c-49ea-8c3c-e85585df40a3 Code: 0 Trace: [ { file: /var/www/html/nextcloud/apps/files_lock/lib/Storage/LockWrapper.php line: 214 function: checkPermission class: OCA\FilesLock\Storage\LockWrapper" type: -> }, { file: /var/www/html/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line: 301 function: fopen class: OCA\FilesLock\Storage\LockWrapper" type: -> }, { file: /var/www/html/nextcloud/apps/files_versions/lib/Storage.php line: 442 function: fopen class: OCA\FilesLock\Wrapper\Wrapper" type: -> }, { file: /var/www/html/nextcloud/apps/files_versions/lib/Storage.php line: 401 function: copyFileContents class: OCA\Files_Versions\Storage type: :: }, ] } ```
max-nextcloud commented 1 year ago

Ran into another issue while trying to reproduce this locally:

Trace with "Call to a member function getEncryptedVersion() on bool" ```json { "reqId": "RLXJR0sgnUhIXVvjvkEF", "level": 3, "time": "2023-04-13T06:40:05+00:00", "remoteAddr": "192.168.26.5", "user": "user1", "app": "webdav", "method": "MOVE", "url": "/remote.php/dav/versions/user1/versions/11636/1681323757", "message": "Call to a member function getEncryptedVersion() on bool", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36", "version": "27.0.0.0", "exception": { "Exception": "Error", "Message": "Call to a member function getEncryptedVersion() on bool", "Code": 0, "Trace": [ { "file": "/var/www/html/apps/files_versions/lib/Versions/LegacyVersionsBackend.php", "line": 147, "function": "rollback", "class": "OCA\\Files_Versions\\Storage", "type": "::", "args": [ "/test late connect.md", 1681323757, [ "OC\\User\\User" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Versions/VersionManager.php", "line": 97, "function": "rollback", "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend", "type": "->", "args": [ [ "OCA\\Files_Versions\\Versions\\Version" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Sabre/VersionFile.php", "line": 117, "function": "rollback", "class": "OCA\\Files_Versions\\Versions\\VersionManager", "type": "->", "args": [ [ "OCA\\Files_Versions\\Versions\\Version" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Sabre/RestoreFolder.php", "line": 76, "function": "rollBack", "class": "OCA\\Files_Versions\\Sabre\\VersionFile", "type": "->", "args": [] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php", "line": 160, "function": "moveInto", "class": "OCA\\Files_Versions\\Sabre\\RestoreFolder", "type": "->", "args": [ "target", "versions/user1/versions/11636/1681323757", [ "OCA\\Files_Versions\\Sabre\\VersionFile" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php", "line": 612, "function": "move", "class": "Sabre\\DAV\\Tree", "type": "->", "args": [ "versions/user1/versions/11636/1681323757", "versions/user1/restore/target" ] }, { "file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php", "line": 89, "function": "httpMove", "class": "Sabre\\DAV\\CorePlugin", "type": "->", "args": [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 472, "function": "emit", "class": "Sabre\\DAV\\Server", "type": "->", "args": [ "method:MOVE", [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 253, "function": "invokeMethod", "class": "Sabre\\DAV\\Server", "type": "->", "args": [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 321, "function": "start", "class": "Sabre\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/apps/dav/lib/Server.php", "line": 368, "function": "exec", "class": "Sabre\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/apps/dav/appinfo/v2/remote.php", "line": 35, "function": "exec", "class": "OCA\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/remote.php", "line": 172, "args": [ "/var/www/html/apps/dav/appinfo/v2/remote.php" ], "function": "require_once" } ], "File": "/var/www/html/apps/files_versions/lib/Storage.php", "Line": 402, "message": "Call to a member function getEncryptedVersion() on bool", "exception": {}, "CustomMessage": "Call to a member function getEncryptedVersion() on bool" } } ```
Trace without object storage. Exception is thrown in `rename` rather than `fopen` ```json { "reqId": "czbcnPKTccY7Ca1V8Y1u", "level": 3, "time": "2023-04-13T07:24:35+00:00", "remoteAddr": "192.168.26.3", "user": "admin", "app": "webdav", "method": "MOVE", "url": "/remote.php/dav/versions/admin/versions/123/1681370644", "message": "\"files/test-locking/revert to old version while locked.md\" is locked, existing lock on file: files_lock/c3491e5a-68f1-4769-84d4-3a44bc7b05d0", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36", "version": "27.0.0.0", "exception": { "Exception": "OCP\\Lock\\ManuallyLockedException", "Message": "\"files/test-locking/revert to old version while locked.md\" is locked, existing lock on file: files_lock/c3491e5a-68f1-4769-84d4-3a44bc7b05d0", "Code": 0, "Trace": [ { "file": "/var/www/html/apps/files_lock/lib/Storage/LockWrapper.php", "line": 163, "function": "checkPermissions", "class": "OCA\\FilesLock\\Storage\\LockWrapper", "type": "->", "args": [ "files/test-locking/revert to old version while locked.md", 2 ] }, { "file": "/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php", "line": 276, "function": "rename", "class": "OCA\\FilesLock\\Storage\\LockWrapper", "type": "->", "args": [ "files_versions/test-locking/revert to old version while locked.md.v1681370644", "files/test-locking/revert to old version while locked.md" ] }, { "file": "/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php", "line": 589, "function": "rename", "class": "OC\\Files\\Storage\\Wrapper\\Wrapper", "type": "->", "args": [ "files_versions/test-locking/revert to old version while locked.md.v1681370644", "files/test-locking/revert to old version while locked.md" ] }, { "file": "/var/www/html/apps/files_trashbin/lib/Storage.php", "line": 239, "function": "moveFromStorage", "class": "OC\\Files\\Storage\\Wrapper\\Wrapper", "type": "->", "args": [ [ "OCA\\Files_Trashbin\\Storage", null, [ "OC\\Files\\Cache\\Scanner" ], null, null, [ "OC\\Files\\Cache\\Updater" ] ], "files_versions/test-locking/revert to old version while locked.md.v1681370644", "files/test-locking/revert to old version while locked.md" ] }, { "file": "/var/www/html/apps/files_versions/lib/Storage.php", "line": 464, "function": "moveFromStorage", "class": "OCA\\Files_Trashbin\\Storage", "type": "->", "args": [ [ "OCA\\Files_Trashbin\\Storage", null, [ "OC\\Files\\Cache\\Scanner" ], null, null, [ "OC\\Files\\Cache\\Updater" ] ], "files_versions/test-locking/revert to old version while locked.md.v1681370644", "files/test-locking/revert to old version while locked.md" ] }, { "file": "/var/www/html/apps/files_versions/lib/Storage.php", "line": 414, "function": "copyFileContents", "class": "OCA\\Files_Versions\\Storage", "type": "::", "args": [ [ "OC\\Files\\View" ], "files_versions/test-locking/revert to old version while locked.md.v1681370644", "files/test-locking/revert to old version while locked.md" ] }, { "file": "/var/www/html/apps/files_versions/lib/Versions/LegacyVersionsBackend.php", "line": 147, "function": "rollback", "class": "OCA\\Files_Versions\\Storage", "type": "::", "args": [ "/test-locking/revert to old version while locked.md", 1681370644, [ "OC\\User\\User" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Versions/VersionManager.php", "line": 97, "function": "rollback", "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend", "type": "->", "args": [ [ "OCA\\Files_Versions\\Versions\\Version" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Sabre/VersionFile.php", "line": 117, "function": "rollback", "class": "OCA\\Files_Versions\\Versions\\VersionManager", "type": "->", "args": [ [ "OCA\\Files_Versions\\Versions\\Version" ] ] }, { "file": "/var/www/html/apps/files_versions/lib/Sabre/RestoreFolder.php", "line": 76, "function": "rollBack", "class": "OCA\\Files_Versions\\Sabre\\VersionFile", "type": "->", "args": [] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Tree.php", "line": 160, "function": "moveInto", "class": "OCA\\Files_Versions\\Sabre\\RestoreFolder", "type": "->", "args": [ "target", "versions/admin/versions/123/1681370644", [ "OCA\\Files_Versions\\Sabre\\VersionFile" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/CorePlugin.php", "line": 612, "function": "move", "class": "Sabre\\DAV\\Tree", "type": "->", "args": [ "versions/admin/versions/123/1681370644", "versions/admin/restore/target" ] }, { "file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php", "line": 89, "function": "httpMove", "class": "Sabre\\DAV\\CorePlugin", "type": "->", "args": [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 472, "function": "emit", "class": "Sabre\\DAV\\Server", "type": "->", "args": [ "method:MOVE", [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 253, "function": "invokeMethod", "class": "Sabre\\DAV\\Server", "type": "->", "args": [ [ "Sabre\\HTTP\\Request" ], [ "Sabre\\HTTP\\Response" ] ] }, { "file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php", "line": 321, "function": "start", "class": "Sabre\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/apps/dav/lib/Server.php", "line": 368, "function": "exec", "class": "Sabre\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/apps/dav/appinfo/v2/remote.php", "line": 35, "function": "exec", "class": "OCA\\DAV\\Server", "type": "->", "args": [] }, { "file": "/var/www/html/remote.php", "line": 172, "args": [ "/var/www/html/apps/dav/appinfo/v2/remote.php" ], "function": "require_once" } ], "File": "/var/www/html/apps/files_lock/lib/Storage/LockWrapper.php", "Line": 95, "message": "\"files/test-locking/revert to old version while locked.md\" is locked, existing lock on file: files_lock/c3491e5a-68f1-4769-84d4-3a44bc7b05d0", "exception": {}, "CustomMessage": "\"files/test-locking/revert to old version while locked.md\" is locked, existing lock on file: files_lock/c3491e5a-68f1-4769-84d4-3a44bc7b05d0" } } ```