diff options
Diffstat (limited to 'lib/private/files')
-rw-r--r-- | lib/private/files/cache/scanner.php | 4 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 26 | ||||
-rw-r--r-- | lib/private/files/utils/scanner.php | 7 |
3 files changed, 32 insertions, 5 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index fb60ee5aa53..bfdab16b645 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -186,9 +186,9 @@ class Scanner extends BasicEmitter { } if (!empty($newData)) { $data['fileid'] = $this->addToCache($file, $newData, $fileId); - $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); - \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); } + $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); + \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); } else { $this->removeFromCache($file); } diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 805a2bc1ad0..c80e935b982 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -232,7 +232,11 @@ class Encryption extends Wrapper { $result = $this->storage->rename($path1, $path2); - if ($result && $this->encryptionManager->isEnabled()) { + if ($result && + // versions always use the keys from the original file, so we can skip + // this step for versions + $this->isVersion($path2) === false && + $this->encryptionManager->isEnabled()) { $source = $this->getFullPath($path1); if (!$this->util->isExcluded($source)) { $target = $this->getFullPath($path2); @@ -449,7 +453,7 @@ class Encryption extends Wrapper { public function copyFromStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { // TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed: - // - call $this->storage->moveFromStorage() instead of $this->copyBetweenStorage + // - call $this->storage->copyFromStorage() instead of $this->copyBetweenStorage // - copy the file cache update from $this->copyBetweenStorage to this method // - copy the copyKeys() call from $this->copyBetweenStorage to this method // - remove $this->copyBetweenStorage @@ -469,6 +473,13 @@ class Encryption extends Wrapper { */ private function copyBetweenStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename) { + // for versions we have nothing to do, because versions should always use the + // key from the original file. Just create a 1:1 copy and done + if ($this->isVersion($targetInternalPath) || + $this->isVersion($sourceInternalPath)) { + return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } + // first copy the keys that we reuse the existing file key on the target location // and don't create a new one which would break versions for example. $mount = $this->mountManager->findByStorageId($sourceStorage->getId()); @@ -741,4 +752,15 @@ class Encryption extends Wrapper { return false; } + /** + * check if path points to a files version + * + * @param $path + * @return bool + */ + protected function isVersion($path) { + $normalized = Filesystem::normalizePath($path); + return substr($normalized, 0, strlen('/files_versions/')) === '/files_versions/'; + } + } diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index c70f4beb31d..558a1fba028 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -99,7 +99,12 @@ class Scanner extends PublicEmitter { $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); }); - + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); + }); + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); + }); // propagate etag and mtimes when files are changed or removed $propagator = $this->propagator; $propagatorListener = function ($path) use ($mount, $propagator) { |