Skip to content

Commit aa06861

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: handle case where we can't get the filesize after open in dav get
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent dc1e8d5 commit aa06861

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,15 @@ public function get() {
474474
}
475475
}
476476

477+
$logger = Server::get(LoggerInterface::class);
477478
// comparing current file size with the one in DB
478479
// if different, fix DB and refresh cache.
480+
//
479481
$fsSize = $this->fileView->filesize($this->getPath());
480-
if ($this->getSize() !== $fsSize) {
481-
$logger = Server::get(LoggerInterface::class);
482+
if ($fsSize === false) {
483+
$logger->warning('file not found on storage after successfully opening it');
484+
throw new ServiceUnavailable($this->l10n->t('Failed to get size for : %1$s', [$this->getPath()]));
485+
} elseif ($this->getSize() !== $fsSize) {
482486
$logger->warning('fixing cached size of file id=' . $this->getId() . ', cached size was ' . $this->getSize() . ', but the filesystem reported a size of ' . $fsSize);
483487

484488
$this->getFileInfo()->getStorage()->getUpdater()->update($this->getFileInfo()->getInternalPath());

0 commit comments

Comments
 (0)