Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Pass size difference for mkdir/file_put_content operations to speed u…
…p correcting the folder size

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Dec 22, 2022
commit cc7c4679a4b4948825ac20f018629c3e51e07ea4
14 changes: 10 additions & 4 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
use OC\Files\Storage\Storage;
use OC\User\LazyUser;
use OC\Share\Share;
use OC\User\User;
use OCA\Files_Sharing\SharedMount;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
Expand Down Expand Up @@ -316,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);
}
}

Expand Down Expand Up @@ -1175,6 +1174,7 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
$this->unlockFile($path, ILockingProvider::LOCK_SHARED);
throw $e;
}
$previousSize = $storage->filesize($internalPath);
}
try {
if (!is_null($extraParam)) {
Expand All @@ -1195,7 +1195,13 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
$this->removeUpdate($storage, $internalPath);
}
if ($result !== false && 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' && isset($previousSize)) {
$size = $result - $previousSize;
}
$this->writeUpdate($storage, $internalPath, null, $size);
}
if ($result !== false && in_array('touch', $hooks)) {
$this->writeUpdate($storage, $internalPath, $extraParam);
Expand Down