Skip to content

Commit

Permalink
delete filecache entries when the object doesn't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Sep 20, 2023
1 parent 3f61e6d commit 37c4da8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,27 @@ public function fopen($path, $mode) {
case 'rb':
$stat = $this->stat($path);
if (is_array($stat)) {
$urn = $this->getURN($stat['fileid']);

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

try {
return $this->objectStore->readObject($this->getURN($stat['fileid']));
return $this->objectStore->readObject($urn);
} catch (NotFoundException $e) {
$this->logger->logException($e, [
'app' => 'objectstore',
'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
'message' => 'Could not get object ' . $urn . ' for file ' . $path,
]);
$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']);
throw $e;
} catch (\Exception $ex) {
$this->logger->logException($ex, [
'app' => 'objectstore',
'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path,
'message' => 'Could not get object ' . $urn . ' for file ' . $path,
]);
return false;
}
Expand Down

0 comments on commit 37c4da8

Please sign in to comment.