Skip to content

Commit

Permalink
fix: Only read unencrypted_size when file is actually encrypted
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jul 12, 2023
1 parent ca50d98 commit bf888b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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 @@ -205,7 +205,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 @@ -227,7 +227,7 @@ public function getMTime() {
* @return bool
*/
public function isEncrypted() {
return $this->data['encrypted'];
return $this->data['encrypted'] ?? false;
}

/**
Expand Down

0 comments on commit bf888b3

Please sign in to comment.