Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-08-16 18:17:51 +0300
committerRobin Appelman <robin@icewind.nl>2022-08-23 17:45:47 +0300
commitc644716305e928e223be429fa818f46d0dd327e5 (patch)
tree246e49fae4cb2d005040603d91381d33ec17aab2
parentc0da67ccddb1f1f41c9f43288f2103fb04da5884 (diff)
trigger a rescan when trying to fopen a file that exists in cache but not on diskfopen-not-found-rescan-23
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--lib/private/Files/Storage/Local.php9
-rw-r--r--lib/private/Files/View.php12
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 6406beaeebc..851df902133 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -149,6 +149,9 @@ class Local extends \OC\Files\Storage\Common {
public function stat($path) {
$fullPath = $this->getSourcePath($path);
clearstatcache(true, $fullPath);
+ if (!file_exists($fullPath)) {
+ return false;
+ }
$statResult = @stat($fullPath);
if (PHP_INT_SIZE === 4 && $statResult && !$this->is_dir($path)) {
$filesize = $this->filesize($path);
@@ -359,8 +362,12 @@ class Local extends \OC\Files\Storage\Common {
}
public function fopen($path, $mode) {
+ $sourcePath = $this->getSourcePath($path);
+ if (!file_exists($sourcePath) && $mode === 'r') {
+ return false;
+ }
$oldMask = umask(022);
- $result = fopen($this->getSourcePath($path), $mode);
+ $result = @fopen($sourcePath, $mode);
umask($oldMask);
return $result;
}
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index ea773007ba6..786331f8210 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1002,7 +1002,17 @@ class View {
\OC::$server->getLogger()->info('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends');
}
- return $this->basicOperation('fopen', $path, $hooks, $mode);
+ $handle = $this->basicOperation('fopen', $path, $hooks, $mode);
+ if (!$handle && $mode === 'r') {
+ // trying to read a file that isn't on disk, check if the cache is out of sync and rescan if needed
+ $mount = $this->getMount($path);
+ $internalPath = $mount->getInternalPath($this->getAbsolutePath($path));
+ $storage = $mount->getStorage();
+ if ($storage->getCache()->inCache($internalPath) && !$storage->file_exists($path)) {
+ $this->writeUpdate($storage, $internalPath);
+ }
+ }
+ return $handle;
}
/**