Skip to content

Commit

Permalink
fix: Only store unencrypted_size if path should be 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 Sep 12, 2023
1 parent e9df5b2 commit 19cf570
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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 @@ -1087,7 +1087,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 19cf570

Please sign in to comment.