From 56ca54a868500537151e7a307a1d71fd6e0cecc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 2 Sep 2021 20:43:08 +0200 Subject: [PATCH] Pass size difference for mkdir/file_put_content operations to speed up correcting the folder size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/Files/View.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 113290e2686fb..232609733010a 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -315,12 +315,12 @@ public function enableCacheUpdate() { $this->updaterEnabled = true; } - protected function writeUpdate(Storage $storage, $internalPath, $time = null) { + protected function writeUpdate(Storage $storage, $internalPath, $time = null, $size = null) { if ($this->updaterEnabled) { if (is_null($time)) { $time = time(); } - $storage->getUpdater()->update($internalPath, $time); + $storage->getUpdater()->update($internalPath, $time, $size); } } @@ -1183,7 +1183,13 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu $this->removeUpdate($storage, $internalPath); } if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') { - $this->writeUpdate($storage, $internalPath); + $size = null; + if ($operation === 'mkdir') { + $size = 0; + } elseif ($operation === 'file_put_contents') { + $size = $result; + } + $this->writeUpdate($storage, $internalPath, null, $size); } if ($result && in_array('touch', $hooks)) { $this->writeUpdate($storage, $internalPath, $extraParam);