Merge pull request #58550 from nextcloud/dav-open-size-not-found

handle case where we can't get the filesize after open in dav get
This commit is contained in:
Ferdinand Thiessen 2026-03-05 13:24:52 +01:00 committed by GitHub
commit 5d84d79c4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -480,11 +480,15 @@ class File extends Node implements IFile {
}
}
$logger = Server::get(LoggerInterface::class);
// comparing current file size with the one in DB
// if different, fix DB and refresh cache.
//
$fsSize = $this->fileView->filesize($this->getPath());
if ($this->getSize() !== $fsSize) {
$logger = Server::get(LoggerInterface::class);
if ($fsSize === false) {
$logger->warning('file not found on storage after successfully opening it');
throw new ServiceUnavailable($this->l10n->t('Failed to get size for : %1$s', [$this->getPath()]));
} elseif ($this->getSize() !== $fsSize) {
$logger->warning('fixing cached size of file id=' . $this->getId() . ', cached size was ' . $this->getSize() . ', but the filesystem reported a size of ' . $fsSize);
$this->getFileInfo()->getStorage()->getUpdater()->update($this->getFileInfo()->getInternalPath());