Skip to content

Commit 3c0c332

Browse files
committed
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 2ef2d6b commit 3c0c332

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
@@ -1210,6 +1210,9 @@ public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, str
12101210
&& $sourceCache->hasEncryptionWrapper()
12111211
&& !$this->shouldEncrypt($targetPath)) {
12121212
$data['encrypted'] = 0;
1213+
// normalizeData() prefers 'encryptedVersion' over 'encrypted' when both are
1214+
// set, so it has to be cleared too or the mark above gets ignored
1215+
unset($data['encryptedVersion']);
12131216
}
12141217

12151218
$fileId = $this->put($targetPath, $data);
@@ -1243,6 +1246,11 @@ private function cacheEntryToArray(ICacheEntry $entry): array {
12431246
if ($entry instanceof CacheEntry && isset($entry['scan_permissions'])) {
12441247
$data['permissions'] = $entry['scan_permissions'];
12451248
}
1249+
1250+
if ($entry->isEncrypted() && isset($entry['encryptedVersion'])) {
1251+
$data['encryptedVersion'] = $entry['encryptedVersion'];
1252+
}
1253+
12461254
return $data;
12471255
}
12481256

0 commit comments

Comments
 (0)