]> source.dussan.org Git - nextcloud-server.git/commitdiff
Store the shared propagator instance 810/head
authorVincent Petry <pvince81@owncloud.com>
Mon, 18 Jul 2016 09:35:14 +0000 (11:35 +0200)
committerBjoern Schiessle <bjoern@schiessle.org>
Wed, 10 Aug 2016 08:57:49 +0000 (10:57 +0200)
This instead of recreating it for every call.

apps/files_sharing/lib/sharedstorage.php
lib/private/Files/Utils/Scanner.php

index 8e9a0f41229bae9c2ef8bda8a0a6dd80f9998c07..92900ccda6969c7952b8ef4fa1e8bd8ad96fdce5 100644 (file)
@@ -319,10 +319,15 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
        }
 
        public function getPropagator($storage = null) {
+               if (isset($this->propagator)) {
+                       return $this->propagator;
+               }
+
                if (!$storage) {
                        $storage = $this;
                }
-               return new \OCA\Files_Sharing\SharedPropagator($storage, \OC::$server->getDatabaseConnection());
+               $this->propagator = new \OCA\Files_Sharing\SharedPropagator($storage, \OC::$server->getDatabaseConnection());
+               return $this->propagator;
        }
 
        public function getOwner($path) {
index f672cc75744c195c531c7e8b0ddac30f60aec8b3..d26c601be1aed3497b86036abe0c561a4c62e1bb 100644 (file)
@@ -139,9 +139,10 @@ class Scanner extends PublicEmitter {
                                $this->triggerPropagator($storage, $path);
                        });
 
-                       $storage->getPropagator()->beginBatch();
+                       $propagator = $storage->getPropagator();
+                       $propagator->beginBatch();
                        $scanner->backgroundScan();
-                       $storage->getPropagator()->commitBatch();
+                       $propagator->commitBatch();
                }
        }
 
@@ -190,14 +191,15 @@ class Scanner extends PublicEmitter {
                                $this->db->beginTransaction();
                        }
                        try {
-                               $storage->getPropagator()->beginBatch();
+                               $propagator = $storage->getPropagator();
+                               $propagator->beginBatch();
                                $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
                                $cache = $storage->getCache();
                                if ($cache instanceof Cache) {
                                        // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner
                                        $cache->correctFolderSize($relativePath);
                                }
-                               $storage->getPropagator()->commitBatch();
+                               $propagator->commitBatch();
                        } catch (StorageNotAvailableException $e) {
                                $this->logger->error('Storage ' . $storage->getId() . ' not available');
                                $this->logger->logException($e);