Skip to content

Commit 0447dc6

Browse files
mejo-backportbot[bot]
authored andcommitted
updateEncryptedVersion: cleanup on target if cache already got renamed
When moving a file to trash with encryption enabled, the cache gets moved before the actual file. According to @icewind1991 this is in order to not break object storage. When moving a file from an unencrypted storage (e.g. a collectives storage) to the encrypted trashbin storage, this causes errors, see This commit fixes it by doing `updateEncryptedVersion()` on the target cache entry *if* the source cache entry doesn't exist anymore, but the corresponding target cache entry does exist already. Fixes: #26544 Signed-off-by: Jonas Meurer <[email protected]>
1 parent 5881082 commit 0447dc6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/private/Files/Storage/Wrapper/Encryption.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,16 @@ private function updateEncryptedVersion(Storage\IStorage $sourceStorage, $source
666666
'encrypted' => $isEncrypted,
667667
];
668668
if ($isEncrypted) {
669-
$encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'];
669+
$sourceCacheEntry = $sourceStorage->getCache()->get($sourceInternalPath);
670+
$targetCacheEntry = $this->getCache()->get($targetInternalPath);
671+
672+
// Rename of the cache already happened, so we do the cleanup on the target
673+
if ($sourceCacheEntry === false && $targetCacheEntry !== false) {
674+
$encryptedVersion = $targetCacheEntry['encryptedVersion'];
675+
$isRename = false;
676+
} else {
677+
$encryptedVersion = $sourceCacheEntry['encryptedVersion'];
678+
}
670679

671680
// In case of a move operation from an unencrypted to an encrypted
672681
// storage the old encrypted version would stay with "0" while the

0 commit comments

Comments
 (0)