Skip to content

Commit 5cb2713

Browse files
authored
Merge pull request #38808 from nextcloud/bugfix/noid/store-unencrypted-homefolder
2 parents 387cf9e + 13b9dd2 commit 5cb2713

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

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
@@ -207,7 +207,7 @@ public function getSize($includeMounts = true) {
207207
if ($includeMounts) {
208208
$this->updateEntryfromSubMounts();
209209

210-
if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
210+
if ($this->isEncrypted() && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
211211
return $this->data['unencrypted_size'];
212212
} else {
213213
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
@@ -229,7 +229,7 @@ public function getMTime() {
229229
* @return bool
230230
*/
231231
public function isEncrypted() {
232-
return $this->data['encrypted'];
232+
return $this->data['encrypted'] ?? false;
233233
}
234234

235235
/**

lib/private/Files/ObjectStore/ObjectStoreStorage.php

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

561561
if ($exists) {
562+
// Always update the unencrypted size, for encryption the Encryption wrapper will update this afterwards anyways
563+
$stat['unencrypted_size'] = $stat['size'];
562564
$this->getCache()->update($fileId, $stat);
563565
} else {
564566
if (!$this->validateWrites || $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
@@ -1071,7 +1071,7 @@ public function writeStream(string $path, $stream, int $size = null): int {
10711071

10721072
// object store, stores the size after write and doesn't update this during scan
10731073
// manually store the unencrypted size
1074-
if ($result && $this->getWrapperStorage()->instanceOfStorage(ObjectStoreStorage::class)) {
1074+
if ($result && $this->getWrapperStorage()->instanceOfStorage(ObjectStoreStorage::class) && $this->shouldEncrypt($path)) {
10751075
$this->getCache()->put($path, ['unencrypted_size' => $count]);
10761076
}
10771077

0 commit comments

Comments
 (0)