Skip to content

Commit 26ba3ca

Browse files
icewind1991susnux
authored andcommitted
fix: handle case where we can't get the filesize after open in dav get
Signed-off-by: Robin Appelman <[email protected]>
1 parent 85b0dcc commit 26ba3ca

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
@@ -480,11 +480,15 @@ public function get() {
480480
}
481481
}
482482

483+
$logger = Server::get(LoggerInterface::class);
483484
// comparing current file size with the one in DB
484485
// if different, fix DB and refresh cache.
486+
//
485487
$fsSize = $this->fileView->filesize($this->getPath());
486-
if ($this->getSize() !== $fsSize) {
487-
$logger = Server::get(LoggerInterface::class);
488+
if ($fsSize === false) {
489+
$logger->warning('file not found on storage after successfully opening it');
490+
throw new ServiceUnavailable($this->l10n->t('Failed to get size for : %1$s', [$this->getPath()]));
491+
} elseif ($this->getSize() !== $fsSize) {
488492
$logger->warning('fixing cached size of file id=' . $this->getId() . ', cached size was ' . $this->getSize() . ', but the filesystem reported a size of ' . $fsSize);
489493

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

0 commit comments

Comments
 (0)