diff options
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/l10n/lv.js | 10 | ||||
-rw-r--r-- | apps/encryption/l10n/lv.json | 10 | ||||
-rw-r--r-- | apps/encryption/lib/Crypto/EncryptAll.php | 23 | ||||
-rw-r--r-- | apps/encryption/lib/Session.php | 2 | ||||
-rw-r--r-- | apps/encryption/tests/Crypto/EncryptAllTest.php | 33 |
5 files changed, 36 insertions, 42 deletions
diff --git a/apps/encryption/l10n/lv.js b/apps/encryption/l10n/lv.js index 4e4d6b4ade3..b44cc20db29 100644 --- a/apps/encryption/l10n/lv.js +++ b/apps/encryption/l10n/lv.js @@ -2,16 +2,16 @@ OC.L10N.register( "encryption", { "Missing recovery key password" : "Pazudusi atkopšanas atslēgas parole", - "Please repeat the recovery key password" : "Lūdzu atkārtot atgūšanas atslēgas paroli", + "Please repeat the recovery key password" : "Lūgums atkārtot atkopes atslēgas paroli", "Repeated recovery key password does not match the provided recovery key password" : "Atkārtota atkopšanas atslēgas parole nesakrīt ar izsniegto atkopšanas atslēgu paroli", "Recovery key successfully enabled" : "Atkopšanas atslēga ir veiksmīgi iespējota", - "Could not enable recovery key. Please check your recovery key password!" : "Atkopšanas atslēgu nevarēja iespējot. Lūdzu, pārbaudiet atkopšanas atslēgas paroli!", + "Could not enable recovery key. Please check your recovery key password!" : "Atkopes atslēgu nevarēja iespējot. Lūgums pārbaudīt atkopes atslēgas paroli.", "Recovery key successfully disabled" : "Atkopšanas atslēga ir veiksmīgi deaktivizēta", - "Could not disable recovery key. Please check your recovery key password!" : "Atkopšanas atslēgu nevarēja atspējot. Lūdzu, pārbaudiet atkopšanas atslēgas paroli!", + "Could not disable recovery key. Please check your recovery key password!" : "Atkopes atslēgu nevarēja atspējot. Lūgums pārbaudīt atkopes atslēgas paroli.", "Missing parameters" : "Trūkstošos parametrs", "Please provide the old recovery password" : "Lūgums norādīt iepriekšējo atkopes paroli", - "Please provide a new recovery password" : "Lūdzu, ievadiet jaunu paroli", - "Please repeat the new recovery password" : "Lūdzu, atkārtojiet jauno atkopšanas paroli", + "Please provide a new recovery password" : "Lūgums norādīt jaunu atkopes paroli", + "Please repeat the new recovery password" : "Lūgums atkārtot jauno atkopes paroli", "Password successfully changed." : "Parole veiksmīgi nomainīta.", "Could not change the password. Maybe the old password was not correct." : "Nevarēja mainīt paroli. Varbūt vecā parole nav pareiza.", "Recovery Key disabled" : "Atkopšanas atslēga deaktivizēta", diff --git a/apps/encryption/l10n/lv.json b/apps/encryption/l10n/lv.json index 4bf8d7fce8e..42787888d86 100644 --- a/apps/encryption/l10n/lv.json +++ b/apps/encryption/l10n/lv.json @@ -1,15 +1,15 @@ { "translations": { "Missing recovery key password" : "Pazudusi atkopšanas atslēgas parole", - "Please repeat the recovery key password" : "Lūdzu atkārtot atgūšanas atslēgas paroli", + "Please repeat the recovery key password" : "Lūgums atkārtot atkopes atslēgas paroli", "Repeated recovery key password does not match the provided recovery key password" : "Atkārtota atkopšanas atslēgas parole nesakrīt ar izsniegto atkopšanas atslēgu paroli", "Recovery key successfully enabled" : "Atkopšanas atslēga ir veiksmīgi iespējota", - "Could not enable recovery key. Please check your recovery key password!" : "Atkopšanas atslēgu nevarēja iespējot. Lūdzu, pārbaudiet atkopšanas atslēgas paroli!", + "Could not enable recovery key. Please check your recovery key password!" : "Atkopes atslēgu nevarēja iespējot. Lūgums pārbaudīt atkopes atslēgas paroli.", "Recovery key successfully disabled" : "Atkopšanas atslēga ir veiksmīgi deaktivizēta", - "Could not disable recovery key. Please check your recovery key password!" : "Atkopšanas atslēgu nevarēja atspējot. Lūdzu, pārbaudiet atkopšanas atslēgas paroli!", + "Could not disable recovery key. Please check your recovery key password!" : "Atkopes atslēgu nevarēja atspējot. Lūgums pārbaudīt atkopes atslēgas paroli.", "Missing parameters" : "Trūkstošos parametrs", "Please provide the old recovery password" : "Lūgums norādīt iepriekšējo atkopes paroli", - "Please provide a new recovery password" : "Lūdzu, ievadiet jaunu paroli", - "Please repeat the new recovery password" : "Lūdzu, atkārtojiet jauno atkopšanas paroli", + "Please provide a new recovery password" : "Lūgums norādīt jaunu atkopes paroli", + "Please repeat the new recovery password" : "Lūgums atkārtot jauno atkopes paroli", "Password successfully changed." : "Parole veiksmīgi nomainīta.", "Could not change the password. Maybe the old password was not correct." : "Nevarēja mainīt paroli. Varbūt vecā parole nav pareiza.", "Recovery Key disabled" : "Atkopšanas atslēga deaktivizēta", diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index d9db616e6f1..4ed75b85a93 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -12,6 +12,7 @@ use OC\Files\View; use OCA\Encryption\KeyManager; use OCA\Encryption\Users\Setup; use OCA\Encryption\Util; +use OCP\Files\FileInfo; use OCP\IConfig; use OCP\IL10N; use OCP\IUser; @@ -202,15 +203,19 @@ class EncryptAll { while ($root = array_pop($directories)) { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { - $path = $root . '/' . $file['name']; - if ($this->rootView->is_dir($path)) { + $path = $root . '/' . $file->getName(); + if ($file->isShared()) { + $progress->setMessage("Skip shared file/folder $path"); + $progress->advance(); + continue; + } elseif ($file->getType() === FileInfo::TYPE_FOLDER) { $directories[] = $path; continue; } else { $progress->setMessage("encrypt files for user $userCount: $path"); $progress->advance(); try { - if ($this->encryptFile($path) === false) { + if ($this->encryptFile($file, $path) === false) { $progress->setMessage("encrypt files for user $userCount: $path (already encrypted)"); $progress->advance(); } @@ -231,17 +236,9 @@ class EncryptAll { } } - /** - * encrypt file - * - * @param string $path - * @return bool - */ - protected function encryptFile($path) { - + protected function encryptFile(FileInfo $fileInfo, string $path): bool { // skip already encrypted files - $fileInfo = $this->rootView->getFileInfo($path); - if ($fileInfo !== false && $fileInfo->isEncrypted()) { + if ($fileInfo->isEncrypted()) { return true; } diff --git a/apps/encryption/lib/Session.php b/apps/encryption/lib/Session.php index e2731d9611d..df1e5d664ad 100644 --- a/apps/encryption/lib/Session.php +++ b/apps/encryption/lib/Session.php @@ -66,7 +66,7 @@ class Session { public function getPrivateKey() { $key = $this->session->get('privateKey'); if (is_null($key)) { - throw new PrivateKeyMissingException('please try to log-out and log-in again', 0); + throw new PrivateKeyMissingException('please try to log-out and log-in again'); } return $key; } diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 9b39c62b650..c56e3375a73 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -82,7 +82,7 @@ class EncryptAllTest extends TestCase { /** * We need format method to return a string - * @var OutputFormatterInterface|\PHPUnit\Framework\MockObject\MockObject + * @var OutputFormatterInterface&MockObject */ $outputFormatter = $this->createMock(OutputFormatterInterface::class); $outputFormatter->method('isDecorated')->willReturn(false); @@ -114,6 +114,13 @@ class EncryptAllTest extends TestCase { ); } + protected function createFileInfoMock($type, string $name): FileInfo&MockObject { + $fileInfo = $this->createMock(FileInfo::class); + $fileInfo->method('getType')->willReturn($type); + $fileInfo->method('getName')->willReturn($name); + return $fileInfo; + } + public function testEncryptAll(): void { /** @var EncryptAll&MockObject $encryptAll */ $encryptAll = $this->getMockBuilder(EncryptAll::class) @@ -299,8 +306,8 @@ class EncryptAllTest extends TestCase { '', null, [ - ['name' => 'foo', 'type' => 'dir'], - ['name' => 'bar', 'type' => 'file'], + $this->createFileInfoMock(FileInfo::TYPE_FOLDER, 'foo'), + $this->createFileInfoMock(FileInfo::TYPE_FILE, 'bar'), ], ], [ @@ -308,26 +315,17 @@ class EncryptAllTest extends TestCase { '', null, [ - ['name' => 'subfile', 'type' => 'file'] + $this->createFileInfoMock(FileInfo::TYPE_FILE, 'subfile'), ], ], ]); - $this->view->expects($this->any())->method('is_dir') - ->willReturnCallback( - function ($path) { - if ($path === '/user1/files/foo') { - return true; - } - return false; - } - ); - $encryptAllCalls = []; $encryptAll->expects($this->exactly(2)) ->method('encryptFile') - ->willReturnCallback(function (string $path) use (&$encryptAllCalls): void { + ->willReturnCallback(function (FileInfo $file, string $path) use (&$encryptAllCalls): bool { $encryptAllCalls[] = $path; + return true; }); $outputFormatter = $this->createMock(OutputFormatterInterface::class); @@ -362,8 +360,7 @@ class EncryptAllTest extends TestCase { $fileInfo = $this->createMock(FileInfo::class); $fileInfo->expects($this->any())->method('isEncrypted') ->willReturn($isEncrypted); - $this->view->expects($this->any())->method('getFileInfo') - ->willReturn($fileInfo); + $this->view->expects($this->never())->method('getFileInfo'); if ($isEncrypted) { @@ -375,7 +372,7 @@ class EncryptAllTest extends TestCase { } $this->assertTrue( - $this->invokePrivate($this->encryptAll, 'encryptFile', ['foo.txt']) + $this->invokePrivate($this->encryptAll, 'encryptFile', [$fileInfo, 'foo.txt']) ); } |