diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2022-10-27 13:29:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-27 13:29:17 +0300 |
commit | 220d71d99798df9d64873be0d67a35989258754e (patch) | |
tree | 17e373dcb16d4e2267d5413501d5519a44f9a726 /lib | |
parent | a117878240a27fe8e400b04e97a5a1d4be35e42c (diff) | |
parent | 8cf947f0dae66649359aac190f1bcd8b5c37cd6b (diff) |
Merge pull request #34410 from nextcloud/backport/33566/stable24
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Storage/Local.php | 9 | ||||
-rw-r--r-- | lib/private/Files/View.php | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index d637b3d194f..990ebdc20ab 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -157,6 +157,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); @@ -373,8 +376,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 c209c8594f7..a909cf46769 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1007,7 +1007,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 (!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; } /** |