diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-10-01 21:47:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-01 21:47:26 +0200 |
commit | ca958de7e9738ba40f5170f9c3d4980374566fa2 (patch) | |
tree | 67d2f0ecf7c65268c0256d89c28c5c4189e93463 /lib/private/Files/View.php | |
parent | 2b854c104433a8c38e2f8bd50d4af70526d06090 (diff) | |
parent | cb51564356e111c79224401b9067d755ac5f5c42 (diff) | |
download | nextcloud-server-ca958de7e9738ba40f5170f9c3d4980374566fa2.tar.gz nextcloud-server-ca958de7e9738ba40f5170f9c3d4980374566fa2.zip |
Merge pull request #33566 from nextcloud/fopen-not-found-rescan
trigger a rescan when trying to fopen a file that exists in cache but not on disk
Diffstat (limited to 'lib/private/Files/View.php')
-rw-r--r-- | lib/private/Files/View.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 294912e698b..986aecf556f 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1003,7 +1003,17 @@ class View { $this->logger->info('Trying to open a file with a mode other than "r" or "w" can cause severe performance issues with some backends', ['app' => 'core']); } - return $this->basicOperation('fopen', $path, $hooks, $mode); + $handle = $this->basicOperation('fopen', $path, $hooks, $mode); + if (!is_resource($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; } /** |