diff options
author | Robin Appelman <robin@icewind.nl> | 2022-06-20 17:56:59 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-08-16 12:07:14 +0200 |
commit | 5e375d9092efd1e40a0ed37dfd2c208598b27bb9 (patch) | |
tree | 1f6004229a3299f57059e913bd507f0193f6932f /lib/private/Files/Cache/Cache.php | |
parent | 6e0123a1d0343b6b850ef6e3b341acf082fa0dce (diff) | |
download | nextcloud-server-5e375d9092efd1e40a0ed37dfd2c208598b27bb9.tar.gz nextcloud-server-5e375d9092efd1e40a0ed37dfd2c208598b27bb9.zip |
Revert "store unencrypted size in the unencrypted_size column"
This reverts commit 8238582e59b7b6ec03318bcf81bf47cce54af320.
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/Cache/Cache.php')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index f23635aa01b..9a7ffdab025 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -37,7 +37,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ - namespace OC\Files\Cache; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; @@ -189,7 +188,6 @@ class Cache implements ICache { $data['fileid'] = (int)$data['fileid']; $data['parent'] = (int)$data['parent']; $data['size'] = 0 + $data['size']; - $data['unencrypted_size'] = 0 + ($data['unencrypted_size'] ?? 0); $data['mtime'] = (int)$data['mtime']; $data['storage_mtime'] = (int)$data['storage_mtime']; $data['encryptedVersion'] = (int)$data['encrypted']; @@ -430,7 +428,7 @@ class Cache implements ICache { protected function normalizeData(array $data): array { $fields = [ 'path', 'parent', 'name', 'mimetype', 'size', 'mtime', 'storage_mtime', 'encrypted', - 'etag', 'permissions', 'checksum', 'storage', 'unencrypted_size']; + 'etag', 'permissions', 'checksum', 'storage']; $extensionFields = ['metadata_etag', 'creation_time', 'upload_time']; $doNotCopyStorageMTime = false; @@ -875,16 +873,8 @@ class Cache implements ICache { $id = $entry['fileid']; $query = $this->getQueryBuilder(); - $query->selectAlias($query->func()->sum('size'), 'size_sum') - ->selectAlias($query->func()->min('size'), 'size_min') - // in case of encryption being enabled after some files are already uploaded, some entries will have an unencrypted_size of 0 and a non-zero size - ->selectAlias($query->func()->sum( - $query->func()->case([ - ['when' => $query->expr()->eq('unencrypted_size', $query->expr()->literal(0, IQueryBuilder::PARAM_INT)), 'then' => 'size'], - ], 'unencrypted_size') - ), 'unencrypted_sum') - ->selectAlias($query->func()->min('unencrypted_size'), 'unencrypted_min') - ->selectAlias($query->func()->max('unencrypted_size'), 'unencrypted_max') + $query->selectAlias($query->func()->sum('size'), 'f1') + ->selectAlias($query->func()->min('size'), 'f2') ->from('filecache') ->whereStorageId($this->getNumericStorageId()) ->whereParent($id); @@ -894,7 +884,7 @@ class Cache implements ICache { $result->closeCursor(); if ($row) { - ['size_sum' => $sum, 'size_min' => $min, 'unencrypted_sum' => $unencryptedSum, 'unencrypted_min' => $unencryptedMin, 'unencrypted_max' => $unencryptedMax] = $row; + [$sum, $min] = array_values($row); $sum = 0 + $sum; $min = 0 + $min; if ($min === -1) { @@ -902,23 +892,8 @@ class Cache implements ICache { } else { $totalSize = $sum; } - if ($unencryptedMin === -1 || $min === -1) { - $unencryptedTotal = $unencryptedMin; - } else { - $unencryptedTotal = $unencryptedSum; - } if ($entry['size'] !== $totalSize) { - // only set unencrypted size for a folder if any child entries have it set - if ($unencryptedMax > 0) { - $this->update($id, [ - 'size' => $totalSize, - 'unencrypted_size' => $unencryptedTotal, - ]); - } else { - $this->update($id, [ - 'size' => $totalSize, - ]); - } + $this->update($id, ['size' => $totalSize]); } } } |