Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: delete filecache entries when the object doesn't exist
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 4, 2025
commit d0c5ead5107bd4cdd461e1ea344970c87418abf7
10 changes: 7 additions & 3 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,16 @@ public function fopen(string $path, string $mode) {
case 'rb':
$stat = $this->stat($path);
if (is_array($stat)) {
$urn = $this->getURN($stat['fileid']);

$filesize = $stat['size'] ?? 0;
// Reading 0 sized files is a waste of time
if ($filesize === 0) {
return fopen('php://memory', $mode);
}

try {
$handle = $this->objectStore->readObject($this->getURN($stat['fileid']));
$handle = $this->objectStore->readObject($urn);
if ($handle === false) {
return false; // keep backward compatibility
}
Expand All @@ -313,16 +315,18 @@ public function fopen(string $path, string $mode) {
return $handle;
} catch (NotFoundException $e) {
$this->logger->error(
'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
'Could not get object ' . $urn . ' for file ' . $path,
[
'app' => 'objectstore',
'exception' => $e,
]
);
$this->logger->warning("removing filecache entry for object that doesn't seem to exist on the object store. " . json_encode($stat));
$this->getCache()->remove((int)$stat['fileid']);

Check failure

Code scanning / Psalm

InvalidArgument

Argument 1 of OC\Files\Cache\Cache::remove expects string, but int provided
throw $e;
} catch (\Exception $e) {
$this->logger->error(
'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
'Could not get object ' . $urn . ' for file ' . $path,
[
'app' => 'objectstore',
'exception' => $e,
Expand Down