diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-10-13 16:15:00 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-16 21:41:51 +0200 |
commit | 54cea05271b887f1c8062c034741df869bc0f055 (patch) | |
tree | 586bd095348130cc3dd4b7f90088bafe0dbfcb4c /apps/files_versions | |
parent | 0c6c36d0c547187dd2c46bdd45f6a718462a8853 (diff) | |
download | nextcloud-server-54cea05271b887f1c8062c034741df869bc0f055.tar.gz nextcloud-server-54cea05271b887f1c8062c034741df869bc0f055.zip |
Fix preserving file ids when restoring a file with object storage
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/storage.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php index fd51a54b108..ae86b6741b5 100644 --- a/apps/files_versions/lib/storage.php +++ b/apps/files_versions/lib/storage.php @@ -347,7 +347,20 @@ class Storage { $view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE); $view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE); - $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2); + // TODO add a proper way of overwriting a file while maintaining file ids + if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) { + $source = $storage1->fopen($internalPath1, 'r'); + $target = $storage2->fopen($internalPath2, 'w'); + list(, $result) = \OC_Helper::streamCopy($source, $target); + fclose($source); + fclose($target); + + if ($result !== false) { + $storage1->unlink($internalPath1); + } + } else { + $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2); + } $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE); $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE); |