Merge pull request #39152 from nextcloud/backport/39115/stable26

[stable26] fix(sse): don't update uncached files
This commit is contained in:
Arthur Schiwon 2023-07-06 18:42:59 +02:00 committed by GitHub
commit e4e608caac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
* @author Vincent Petry <vincent@nextcloud.com>
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* @license AGPL-3.0
*
@ -141,21 +142,28 @@ class Encryption extends Wrapper {
$info = $this->getCache()->get($path);
if (isset($this->unencryptedSize[$fullPath])) {
$size = $this->unencryptedSize[$fullPath];
// update file cache
if ($info instanceof ICacheEntry) {
$info['encrypted'] = $info['encryptedVersion'];
} else {
if (!is_array($info)) {
$info = [];
}
$info['encrypted'] = true;
$info = new CacheEntry($info);
}
if ($size !== $info->getUnencryptedSize()) {
$this->getCache()->update($info->getId(), [
'unencrypted_size' => $size
]);
// Update file cache (only if file is already cached).
// Certain files are not cached (e.g. *.part).
if (isset($info['fileid'])) {
if ($info instanceof ICacheEntry) {
$info['encrypted'] = $info['encryptedVersion'];
} else {
/**
* @psalm-suppress RedundantCondition
*/
if (!is_array($info)) {
$info = [];
}
$info['encrypted'] = true;
$info = new CacheEntry($info);
}
if ($size !== $info->getUnencryptedSize()) {
$this->getCache()->update($info->getId(), [
'unencrypted_size' => $size
]);
}
}
return $size;