Skip to content

Commit f077b26

Browse files
authored
Merge pull request #40381 from nextcloud/backport/38808/stable25
2 parents cb9a724 + 8ddcebe commit f077b26

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/private/Files/Cache/CacheEntry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function __clone() {
134134
}
135135

136136
public function getUnencryptedSize(): int {
137-
if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
137+
if ($this->data['encrypted'] && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
138138
return $this->data['unencrypted_size'];
139139
} else {
140140
return $this->data['size'] ?? 0;

lib/private/Files/FileInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function getSize($includeMounts = true) {
210210
if ($includeMounts) {
211211
$this->updateEntryfromSubMounts();
212212

213-
if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
213+
if ($this->isEncrypted() && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
214214
return $this->data['unencrypted_size'];
215215
} else {
216216
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
@@ -232,7 +232,7 @@ public function getMTime() {
232232
* @return bool
233233
*/
234234
public function isEncrypted() {
235-
return $this->data['encrypted'];
235+
return $this->data['encrypted'] ?? false;
236236
}
237237

238238
/**

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ public function writeStream(string $path, $stream, int $size = null): int {
521521
}
522522

523523
if ($exists) {
524+
// Always update the unencrypted size, for encryption the Encryption wrapper will update this afterwards anyways
525+
$stat['unencrypted_size'] = $stat['size'];
524526
$this->getCache()->update($fileId, $stat);
525527
} else {
526528
if ($this->objectStore->objectExists($urn)) {

lib/private/Files/Storage/Wrapper/Encryption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ public function writeStream(string $path, $stream, int $size = null): int {
10871087

10881088
// object store, stores the size after write and doesn't update this during scan
10891089
// manually store the unencrypted size
1090-
if ($result && $this->getWrapperStorage()->instanceOfStorage(ObjectStoreStorage::class)) {
1090+
if ($result && $this->getWrapperStorage()->instanceOfStorage(ObjectStoreStorage::class) && $this->shouldEncrypt($path)) {
10911091
$this->getCache()->put($path, ['unencrypted_size' => $count]);
10921092
}
10931093

0 commit comments

Comments
 (0)