Skip to content

Commit e69a7f6

Browse files
leftybournesbackportbot[bot]
authored andcommitted
fix(files): preserve encryptedVersion when copying cache entries
Cache::copyFromCache() rebuilt the target's cache row via cacheEntryToArray(), which only carried over a boolean `encrypted` flag and dropped the real `encryptedVersion` count. Since View::copy() unconditionally calls copyFromCache() after the storage copy completes, this silently overwrote the correct encryptedVersion that Encryption::updateEncryptedVersion() had just set, collapsing it back to 0/1 on every copy of a file whose encryptedVersion was above 1. cacheEntryToArray() now includes the source entry's encryptedVersion when it is encrypted. The existing encrypted-to-non-encrypted-storage override in copyFromCache() also clears encryptedVersion alongside `encrypted`, since normalizeData() prefers encryptedVersion over `encrypted` when both are present in the update data. Signed-off-by: Kent Delante <kent@delante.me> Assisted-by: ClaudeCode:claude-sonnet-5
1 parent 2146c78 commit e69a7f6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/private/Files/Cache/Cache.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
12551255
&& $sourceCache->hasEncryptionWrapper()
12561256
&& !$this->shouldEncrypt($targetPath)) {
12571257
$data['encrypted'] = 0;
1258+
// normalizeData() prefers 'encryptedVersion' over 'encrypted' when both are
1259+
// set, so it has to be cleared too or the mark above gets ignored
1260+
unset($data['encryptedVersion']);
12581261
}
12591262

12601263
$fileId = $this->put($targetPath, $data);
@@ -1288,6 +1291,11 @@ private function cacheEntryToArray(ICacheEntry $entry): array {
12881291
if ($entry instanceof CacheEntry && isset($entry['scan_permissions'])) {
12891292
$data['permissions'] = $entry['scan_permissions'];
12901293
}
1294+
1295+
if ($entry->isEncrypted() && isset($entry['encryptedVersion'])) {
1296+
$data['encryptedVersion'] = $entry['encryptedVersion'];
1297+
}
1298+
12911299
return $data;
12921300
}
12931301

0 commit comments

Comments
 (0)