diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2022-12-01 15:42:07 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2022-12-01 15:42:15 -0100 |
commit | cc639a887734396158da0073b662711e8334b7ee (patch) | |
tree | d2b466ce27ffdc4ab3dba70950188f63692664f9 /apps/dav/lib | |
parent | a51f0dbc6c93738dedd89885ffe816d97179ba1e (diff) | |
download | nextcloud-server-cc639a887734396158da0073b662711e8334b7ee.tar.gz nextcloud-server-cc639a887734396158da0073b662711e8334b7ee.zip |
compare cached filesize on download
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/File.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 94632b265db..3a871b06259 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -45,11 +45,11 @@ use OC\Files\Stream\HashWrapper; use OC\Files\View; use OC\Metadata\FileMetadata; use OCA\DAV\AppInfo\Application; +use OCA\DAV\Connector\Sabre\Exception\BadGateway; use OCA\DAV\Connector\Sabre\Exception\EntityTooLarge; use OCA\DAV\Connector\Sabre\Exception\FileLocked; use OCA\DAV\Connector\Sabre\Exception\Forbidden as DAVForbiddenException; use OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType; -use OCA\DAV\Connector\Sabre\Exception\BadGateway; use OCP\Encryption\Exceptions\GenericEncryptionException; use OCP\Files\EntityTooLargeException; use OCP\Files\FileInfo; @@ -491,9 +491,21 @@ class File extends Node implements IFile { } catch (\Exception $e) { $this->convertToSabreException($e); } + if ($res === false) { throw new ServiceUnavailable($this->l10n->t('Could not open file')); } + + // comparing current file size with the one in DB + // if different, fix DB and refresh cache. + if ($this->getSize() !== $this->fileView->filesize($this->getPath())) { + $logger = \OC::$server->get(LoggerInterface::class); + $logger->warning('fixing cached size of file id=' . $this->getId()); + + $this->getFileInfo()->getStorage()->getUpdater()->update($this->getFileInfo()->getInternalPath()); + $this->refreshInfo(); + } + return $res; } catch (GenericEncryptionException $e) { // returning 503 will allow retry of the operation at a later point in time |