Skip to content

Commit

Permalink
Merge pull request #40382 from nextcloud/backport/38808/stable24
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr authored Oct 10, 2023
2 parents e867ca0 + 8f3e6c7 commit bef7d10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/CacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function __clone() {
}

public function getUnencryptedSize(): int {
if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
if ($this->data['encrypted'] && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
return $this->data['unencrypted_size'];
} else {
return $this->data['size'] ?? 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function getSize($includeMounts = true) {
if ($includeMounts) {
$this->updateEntryfromSubMounts();

if (isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
if ($this->isEncrypted() && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
return $this->data['unencrypted_size'];
} else {
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
Expand All @@ -235,7 +235,7 @@ public function getMTime() {
* @return bool
*/
public function isEncrypted() {
return $this->data['encrypted'];
return $this->data['encrypted'] ?? false;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ public function writeStream(string $path, $stream, int $size = null): int {
}

if ($exists) {
// Always update the unencrypted size, for encryption the Encryption wrapper will update this afterwards anyways
$stat['unencrypted_size'] = $stat['size'];
$this->getCache()->update($fileId, $stat);
} else {
if ($this->objectStore->objectExists($urn)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ public function writeStream(string $path, $stream, int $size = null): int {

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

Expand Down

0 comments on commit bef7d10

Please sign in to comment.