diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-06-15 11:58:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-15 11:58:50 +0200 |
commit | f163eedfa281099c8ef63ea8e4da138a47228283 (patch) | |
tree | ff43b8cf2d0841addd2a040f70ce489cabf3cd52 | |
parent | 3e9353dd699b4ed9a568bfbf30e115da422f7447 (diff) | |
parent | 01d9ad6b14bc5d9fd6c1140e801e92167b0c7f6a (diff) | |
download | nextcloud-server-f163eedfa281099c8ef63ea8e4da138a47228283.tar.gz nextcloud-server-f163eedfa281099c8ef63ea8e4da138a47228283.zip |
Merge pull request #25102 from owncloud/preview-delete-performance
Preview delete performance
-rw-r--r-- | lib/private/Files/Cache/Updater.php | 18 | ||||
-rw-r--r-- | lib/private/Preview.php | 21 |
2 files changed, 27 insertions, 12 deletions
diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index 4e17c4d778d..361db4b3f85 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -25,6 +25,8 @@ */ namespace OC\Files\Cache; + +use OCP\Files\Cache\ICacheEntry; use OCP\Files\Cache\IUpdater; use OCP\Files\Storage\IStorage; @@ -150,12 +152,20 @@ class Updater implements IUpdater { $parent = ''; } + $entry = $this->cache->get($path); + $this->cache->remove($path); - if ($this->cache instanceof Cache) { - $this->cache->correctFolderSize($parent); - } + $this->correctParentStorageMtime($path); - $this->propagator->propagateChange($path, time()); + if ($entry instanceof ICacheEntry) { + $this->propagator->propagateChange($path, time(), -$entry->getSize()); + } else { + $this->propagator->propagateChange($path, time()); + if ($this->cache instanceof Cache) { + $this->cache->correctFolderSize($parent); + } + } + } /** diff --git a/lib/private/Preview.php b/lib/private/Preview.php index f5e2f6b57e1..8bc262d7047 100644 --- a/lib/private/Preview.php +++ b/lib/private/Preview.php @@ -136,9 +136,9 @@ class Preview { //check if there are preview backends if (!\OC::$server->getPreviewManager() - ->hasProviders() + ->hasProviders() && \OC::$server->getConfig() - ->getSystemValue('enable_previews', true) + ->getSystemValue('enable_previews', true) ) { \OCP\Util::writeLog('core', 'No preview providers exist', \OCP\Util::ERROR); throw new \Exception('No preview providers'); @@ -410,6 +410,10 @@ class Preview { * Deletes all previews of a file */ public function deleteAllPreviews() { + $thumbnailMount = $this->userView->getMount($this->getThumbnailsFolder()); + $propagator = $thumbnailMount->getStorage()->getPropagator(); + $propagator->beginBatch(); + $toDelete = $this->getChildren(); $toDelete[] = $this->getFileInfo(); @@ -422,11 +426,12 @@ class Preview { // .ocTransferId*.part file from chunked file upload. if (!empty($fileId)) { $previewPath = $this->getPreviewPath($fileId); - $this->userView->deleteAll($previewPath); $this->userView->rmdir($previewPath); } } } + + $propagator->commitBatch(); } /** @@ -573,8 +578,8 @@ class Preview { * @return integer[] */ private function applyAspectRatio($askedWidth, $askedHeight, $originalWidth = 0, $originalHeight = 0) { - if(!$originalWidth){ - $originalWidth= $this->maxPreviewWidth; + if (!$originalWidth) { + $originalWidth = $this->maxPreviewWidth; } if (!$originalHeight) { $originalHeight = $this->maxPreviewHeight; @@ -1113,7 +1118,7 @@ class Preview { $preview = null; $previewProviders = \OC::$server->getPreviewManager() - ->getProviders(); + ->getProviders(); foreach ($previewProviders as $supportedMimeType => $providers) { if (!preg_match($supportedMimeType, $this->mimeType)) { continue; @@ -1127,7 +1132,7 @@ class Preview { \OCP\Util::writeLog( 'core', 'Generating preview for "' . $file . '" with "' . get_class($provider) - . '"', \OCP\Util::DEBUG + . '"', \OCP\Util::DEBUG ); /** @var $provider Provider */ @@ -1261,7 +1266,7 @@ class Preview { $absPath = Files\Filesystem::normalizePath($view->getAbsolutePath($path)); $fileInfo = $view->getFileInfo($path); - if($fileInfo === false) { + if ($fileInfo === false) { return; } self::addPathToDeleteFileMapper($absPath, $fileInfo); |