Skip to content

Commit

Permalink
Update cache when file size === 0
Browse files Browse the repository at this point in the history
The conditions were false when $result === 0.
$results here contains the number of written bits.
The correct way of checking for operation success is to check if $result === false

Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Nov 23, 2022
1 parent 9422d80 commit fb73ab2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,14 @@ public function rename($source, $target) {
} else {
$result = false;
}
// moving a file/folder within the same mount point
// moving a file/folder within the same mount point
} elseif ($storage1 === $storage2) {
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
} else {
$result = false;
}
// moving a file/folder between storages (from $storage1 to $storage2)
// moving a file/folder between storages (from $storage1 to $storage2)
} else {
$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
}
Expand Down Expand Up @@ -1047,7 +1047,6 @@ public function toTmpFile($path) {
public function fromTmpFile($tmpFile, $path) {
$this->assertPathLength($path);
if (Filesystem::isValidPath($path)) {

// Get directory that the file is going into
$filePath = dirname($path);

Expand Down Expand Up @@ -1191,13 +1190,13 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu
throw $e;
}

if ($result && in_array('delete', $hooks)) {
if ($result !== false && in_array('delete', $hooks)) {
$this->removeUpdate($storage, $internalPath);
}
if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
if ($result !== false && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
$this->writeUpdate($storage, $internalPath);
}
if ($result && in_array('touch', $hooks)) {
if ($result !== false && in_array('touch', $hooks)) {
$this->writeUpdate($storage, $internalPath, $extraParam);
}

Expand Down Expand Up @@ -1803,7 +1802,6 @@ private function assertPathLength($path) {
* @return boolean
*/
private function targetIsNotShared(IStorage $targetStorage, string $targetInternalPath) {

// note: cannot use the view because the target is already locked
$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
if ($fileId === -1) {
Expand Down

0 comments on commit fb73ab2

Please sign in to comment.