aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2022-12-03 19:53:46 +0100
committerGitHub <noreply@github.com>2022-12-03 19:53:46 +0100
commit82e2a9033fad4917538568e87e8dec8c38ba31df (patch)
tree668010537aa9fdc5a1cb6dc3370de4dbfad89142 /apps/dav
parent9668526d19c25e6daebdf216843538bc07cd3074 (diff)
parentcc639a887734396158da0073b662711e8334b7ee (diff)
downloadnextcloud-server-82e2a9033fad4917538568e87e8dec8c38ba31df.tar.gz
nextcloud-server-82e2a9033fad4917538568e87e8dec8c38ba31df.zip
Merge pull request #34232 from nextcloud/fix/noid/refresh-filesize-on-conflict
compare cached filesize on download
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php14
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