{"action":"created","issue":{"url":"https://api.github.com/repos/owncloud/core/issues/11804","labels_url":"https://api.github.com/repos/owncloud/core/issues/11804/labels{/name}","comments_url":"https://api.github.com/repos/owncloud/core/issues/11804/comments","events_url":"https://api.github.com/repos/owncloud/core/issues/11804/events","html_url":"https://github.com/owncloud/core/issues/11804","id":47005177,"number":11804,"title":"Implement high level file locking","user":{"login":"PVince81","id":277525,"avatar_url":"https://avatars.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/owncloud/core/labels/enhancement","name":"enhancement","color":"02e10c"},{"url":"https://api.github.com/repos/owncloud/core/labels/enhancement%20-%20approved","name":"enhancement - approved","color":"FF9900"},{"url":"https://api.github.com/repos/owncloud/core/labels/p1-urgent","name":"p1-urgent","color":"fc2929"},{"url":"https://api.github.com/repos/owncloud/core/labels/sev1-critical","name":"sev1-critical","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"icewind1991","id":1283854,"avatar_url":"https://avatars.githubusercontent.com/u/1283854?v=3","gravatar_id":"","url":"https://api.github.com/users/icewind1991","html_url":"https://github.com/icewind1991","followers_url":"https://api.github.com/users/icewind1991/followers","following_url":"https://api.github.com/users/icewind1991/following{/other_user}","gists_url":"https://api.github.com/users/icewind1991/gists{/gist_id}","starred_url":"https://api.github.com/users/icewind1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icewind1991/subscriptions","organizations_url":"https://api.github.com/users/icewind1991/orgs","repos_url":"https://api.github.com/users/icewind1991/repos","events_url":"https://api.github.com/users/icewind1991/events{/privacy}","received_events_url":"https://api.github.com/users/icewind1991/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/31","html_url":"https://github.com/owncloud/core/milestones/8.1-current","labels_url":"https://api.github.com/repos/owncloud/core/milestones/31/labels","id":912160,"number":31,"title":"8.1-current","description":"","creator":{"login":"MorrisJobke","id":245432,"avatar_url":"https://avatars.githubusercontent.com/u/245432?v=3","gravatar_id":"","url":"https://api.github.com/users/MorrisJobke","html_url":"https://github.com/MorrisJobke","followers_url":"https://api.github.com/users/MorrisJobke/followers","following_url":"https://api.github.com/users/MorrisJobke/following{/other_user}","gists_url":"https://api.github.com/users/MorrisJobke/gists{/gist_id}","starred_url":"https://api.github.com/users/MorrisJobke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MorrisJobke/subscriptions","organizations_url":"https://api.github.com/users/MorrisJobke/orgs","repos_url":"https://api.github.com/users/MorrisJobke/repos","events_url":"https://api.github.com/users/MorrisJobke/events{/privacy}","received_events_url":"https://api.github.com/users/MorrisJobke/received_events","type":"User","site_admin":false},"open_issues":109,"closed_issues":1212,"state":"open","created_at":"2014-12-22T12:04:01Z","updated_at":"2015-05-21T12:10:14Z","due_on":"2015-04-02T22:00:00Z","closed_at":null},"comments":53,"created_at":"2014-10-28T09:33:54Z","updated_at":"2015-05-21T12:45:00Z","closed_at":null,"body":"Currently the files_locking app only works on storage level, which is not enough to guarantee atomicity of operations. This is because we have hooks and proxies and apps are able to perform additional filesystem operations.\r\n\r\nA high-level file locking mechanism should be implemented to guarantee atomicity of file operations on a higher level.\r\n\r\nFor example, this is what happens when renaming an encrypted file:\r\n1) User renames file\r\n2) System calls `$view->rename()`\r\n3) File is renamed on the storage\r\n4) Encryption keys are renamed\r\n5) Version files are renamed\r\n\r\nSince files_locking only operates on storage level, only step 3) is locked.\r\n\r\nIf after step 3) someone renamed the new file to yet another name, they will get a \"share key not found\" error.\r\n\r\nThe high-level locking mechanism would work as follows:\r\n1) User renames files\r\n2) System calls `$view->rename()`\r\n3) A lock is set on source and target file names\r\n4) File is renamed on the storage\r\n5) Encryption keys are renamed\r\n6) Versions are renamed\r\n7) Lock is released\r\n\r\nAlso note that files_locking does not lock folders.\r\n\r\nThere's also the open question whether parent folders should be locked and whether folder locking is feasible at all.\r\n\r\nHere is an example of what kind of race conditions happen due to lack of high-level locking: https://github.com/owncloud/core/issues/11795\r\n(rename a folder while the sync client is uploading files into it)\r\n\r\n@craigpg @karlitschek @MTRichards @DeepDiver1975 @icewind1991 @schiesbn @bantu "},"comment":{"url":"https://api.github.com/repos/owncloud/core/issues/comments/104257416","html_url":"https://github.com/owncloud/core/issues/11804#issuecomment-104257416","issue_url":"https://api.github.com/repos/owncloud/core/issues/11804","id":104257416,"user":{"login":"PVince81","id":277525,"avatar_url":"https://avatars.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"created_at":"2015-05-21T12:45:00Z","updated_at":"2015-05-21T12:45:00Z","body":"- [ ] think about all the places where we want to explicitly \"lock before a big bunch of operations\" and \"release lock afterwards\". \r\n    - [ ] file upload: we need to bundle everything from \"precondition check\" to \"final rename\" inside a single transaction (currently the precondition check is done early but there is no guarantee that it is still true at the time of the rename)"}}