summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-10-02 17:08:39 +0200
committerRobin Appelman <icewind@owncloud.com>2015-10-02 17:08:39 +0200
commit943c5069d4822802d3c210fcabe80a5364c438ef (patch)
tree376bd8eab3ef968f6a55698ec0e419a409eb6c7d /apps/files_versions/lib
parent8bdffb5ed3d45e026b47e62fc8e07dfd107553e0 (diff)
downloadnextcloud-server-943c5069d4822802d3c210fcabe80a5364c438ef.tar.gz
nextcloud-server-943c5069d4822802d3c210fcabe80a5364c438ef.zip
Lock files when rolling back version
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/storage.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index bdf1811c5f9..cd2077d2922 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -42,6 +42,7 @@ namespace OCA\Files_Versions;
use OCA\Files_Versions\AppInfo\Application;
use OCA\Files_Versions\Command\Expire;
+use OCP\Lock\ILockingProvider;
class Storage {
@@ -337,11 +338,19 @@ class Storage {
* @return bool true for success, false otherwise
*/
private static function copyFileContents($view, $path1, $path2) {
+ /** @var \OC\Files\Storage\Storage $storage1 */
list($storage1, $internalPath1) = $view->resolvePath($path1);
+ /** @var \OC\Files\Storage\Storage $storage2 */
list($storage2, $internalPath2) = $view->resolvePath($path2);
+ $view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
+ $view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
+
$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
+ $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
+ $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
+
return ($result !== false);
}