Merge pull request #30694 from nextcloud/backport/30631/stable22

[stable22] updateEncryptedVersion: cleanup on target if cache already got renamed
This commit is contained in:
Jonas 2022-01-16 10:20:12 +01:00 committed by GitHub
commit 293e5550e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -666,7 +666,16 @@ class Encryption extends Wrapper {
'encrypted' => $isEncrypted,
];
if ($isEncrypted) {
$encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion'];
$sourceCacheEntry = $sourceStorage->getCache()->get($sourceInternalPath);
$targetCacheEntry = $this->getCache()->get($targetInternalPath);
// Rename of the cache already happened, so we do the cleanup on the target
if ($sourceCacheEntry === false && $targetCacheEntry !== false) {
$encryptedVersion = $targetCacheEntry['encryptedVersion'];
$isRename = false;
} else {
$encryptedVersion = $sourceCacheEntry['encryptedVersion'];
}
// In case of a move operation from an unencrypted to an encrypted
// storage the old encrypted version would stay with "0" while the