Skip to content

Commit

Permalink
Pass size difference for mkdir/file_put_content operations to speed u…
Browse files Browse the repository at this point in the history
…p correcting the folder size

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Sep 8, 2021
1 parent 94d168f commit 56ca54a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 56ca54a

Please sign in to comment.