Skip to content

Commit e3a0e64

Browse files
committed
clear is-encrypted cache when trying to fix encrypted version
Signed-off-by: Robin Appelman <[email protected]>
1 parent e9b87c7 commit e3a0e64

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

apps/encryption/lib/Command/FixEncryptedVersion.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
namespace OCA\Encryption\Command;
2424

25+
use OC\Files\Storage\Wrapper\Encryption;
2526
use OC\Files\View;
2627
use OC\ServerNotAvailableException;
2728
use OCA\Encryption\Util;
@@ -165,6 +166,13 @@ private function walkPathOfUser(string $user, string $path, OutputInterface $out
165166
*/
166167
private function verifyFileContent(string $path, OutputInterface $output, bool $ignoreCorrectEncVersionCall = true): bool {
167168
try {
169+
// since we're manually poking around the encrypted state we need to ensure that this isn't cached in the encryption wrapper
170+
$mount = $this->view->getMount($path);
171+
$storage = $mount->getStorage();
172+
if ($storage && $storage->instanceOfStorage(Encryption::class)) {
173+
$storage->clearIsEncryptedCache();
174+
}
175+
168176
/**
169177
* In encryption, the files are read in a block size of 8192 bytes
170178
* Read block size of 8192 and a bit more (808 bytes)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,4 +1095,8 @@ public function writeStream(string $path, $stream, int $size = null): int {
10951095

10961096
return $count;
10971097
}
1098+
1099+
public function clearIsEncryptedCache(): void {
1100+
$this->encryptedPaths->clear();
1101+
}
10981102
}

0 commit comments

Comments
 (0)