Skip to content

Commit fb73ab2

Browse files
committed
Update cache when file size === 0
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>
1 parent 9422d80 commit fb73ab2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/private/Files/View.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,14 @@ public function rename($source, $target) {
821821
} else {
822822
$result = false;
823823
}
824-
// moving a file/folder within the same mount point
824+
// moving a file/folder within the same mount point
825825
} elseif ($storage1 === $storage2) {
826826
if ($storage1) {
827827
$result = $storage1->rename($internalPath1, $internalPath2);
828828
} else {
829829
$result = false;
830830
}
831-
// moving a file/folder between storages (from $storage1 to $storage2)
831+
// moving a file/folder between storages (from $storage1 to $storage2)
832832
} else {
833833
$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
834834
}
@@ -1047,7 +1047,6 @@ public function toTmpFile($path) {
10471047
public function fromTmpFile($tmpFile, $path) {
10481048
$this->assertPathLength($path);
10491049
if (Filesystem::isValidPath($path)) {
1050-
10511050
// Get directory that the file is going into
10521051
$filePath = dirname($path);
10531052

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

1194-
if ($result && in_array('delete', $hooks)) {
1193+
if ($result !== false && in_array('delete', $hooks)) {
11951194
$this->removeUpdate($storage, $internalPath);
11961195
}
1197-
if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
1196+
if ($result !== false && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
11981197
$this->writeUpdate($storage, $internalPath);
11991198
}
1200-
if ($result && in_array('touch', $hooks)) {
1199+
if ($result !== false && in_array('touch', $hooks)) {
12011200
$this->writeUpdate($storage, $internalPath, $extraParam);
12021201
}
12031202

@@ -1803,7 +1802,6 @@ private function assertPathLength($path) {
18031802
* @return boolean
18041803
*/
18051804
private function targetIsNotShared(IStorage $targetStorage, string $targetInternalPath) {
1806-
18071805
// note: cannot use the view because the target is already locked
18081806
$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
18091807
if ($fileId === -1) {

0 commit comments

Comments
 (0)