Skip to content

Commit

Permalink
[stable10] Fix minor wording corrections in command
Browse files Browse the repository at this point in the history
Fix minor wording corrections in the command
and in the test.

Signed-off-by: Sujith H <[email protected]>
  • Loading branch information
sharidas committed Apr 12, 2019
1 parent dada1b4 commit c530242
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
18 changes: 9 additions & 9 deletions apps/encryption/lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ protected function configure() {
parent::configure();

$this
->setName('encryption:fixencryptedversion')
->setName('encryption:fix-encrypted-version')
->setDescription('Fix the encrypted version if the encrypted file(s) are not downloadable.')
->addArgument(
'user',
InputArgument::REQUIRED,
'The user id whose files needs fix'
'The id of the user whose files need fixing'
);
}

protected function execute(InputInterface $input, OutputInterface $output) {
$user = $input->getArgument('user');

if ($user === null) {
$output->writeln("<error>No user provided.</error>\n");
$output->writeln("<error>No user id provided.</error>\n");
}

if ($this->userManager->get($user) === null) {
$output->writeln("<error>User $user does not exist. Please provide a valid user id</error>");
$output->writeln("<error>User id $user does not exist. Please provide a valid user id</error>");
return 1;
}
$this->walkUserFolder($user, $output);
Expand Down Expand Up @@ -143,7 +143,7 @@ private function correctEncryptedVersion($path, OutputInterface $output) {
$fileCache = $cache->get($fileId);

if ($storage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
$output->writeln("<info>The file: $path is a share. Hence kindly fix this by running the script under the owner of share</info>");
$output->writeln("<info>The file: $path is a share. Hence kindly fix this by running the script for the owner of share</info>");
return true;
}

Expand All @@ -155,17 +155,17 @@ private function correctEncryptedVersion($path, OutputInterface $output) {
$cache->put($fileCache->getPath(), $cacheInfo);
$output->writeln("<info>Decrement the encrypted version to $encryptedVersion</info>");
if ($this->verifyFileContent($path, $output, false) === true) {
$output->writeln("<info>Fixed the file $path with version " . $encryptedVersion . "</info>");
$output->writeln("<info>Fixed the file: $path with version " . $encryptedVersion . "</info>");
return true;
}
$encryptedVersion--;
}

//So decrementing did not worked. Now lets increment. Max increment is till 5
//So decrementing did not work. Now lets increment. Max increment is till 5
$increment = 1;
while ($increment <= 5) {
/**
* The wrongEncryptedVersion would not be incremented so nothing to worry here.
* The wrongEncryptedVersion would not be incremented so nothing to worry about here.
* Only the newEncryptedVersion is incremented.
* For example if the wrong encrypted version is 4 then
* cycle1 -> newEncryptedVersion = 5 ( 4 + 1)
Expand All @@ -178,7 +178,7 @@ private function correctEncryptedVersion($path, OutputInterface $output) {
$cache->put($fileCache->getPath(), $cacheInfo);
$output->writeln("<info>Increment the encrypted version to $newEncryptedVersion</info>");
if ($this->verifyFileContent($path, $output, false) === true) {
$output->writeln("<info>Fixed the file $path with version " . $newEncryptedVersion . "</info>");
$output->writeln("<info>Fixed the file: $path with version " . $newEncryptedVersion . "</info>");
return true;
}
$increment++;
Expand Down
13 changes: 7 additions & 6 deletions apps/encryption/tests/Command/FixEncryptedVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace OCA\Encryption\Tests\Command;

use OC\Files\Cache\Cache;
use OC\Files\Filesystem;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\View;
Expand Down Expand Up @@ -121,7 +122,7 @@ public function markTestSkippedIfFilesPrimary() {
* In this test the encrypted version is set to zero whereas it should have been
* set to a positive non zero number.
*/
public function testEncryptedVersionZero() {
public function testEncryptedVersionIsNotZero() {
$this->markTestSkippedIfFilesPrimary();
\OC::$server->getUserSession()->login(self::TEST_ENCRYPTION_VERSION_AFFECTED_USER, 'foo');
$view = new View("/" . self::TEST_ENCRYPTION_VERSION_AFFECTED_USER . "/files");
Expand Down Expand Up @@ -150,7 +151,7 @@ public function testEncryptedVersionZero() {
Attempting to fix the path: /test_enc_version_affected_user1/files/hello.txt
Increment the encrypted version to 1
The file /test_enc_version_affected_user1/files/hello.txt is: OK
Fixed the file /test_enc_version_affected_user1/files/hello.txt with version 1
Fixed the file: /test_enc_version_affected_user1/files/hello.txt with version 1
Verifying the content of file /test_enc_version_affected_user1/files/world.txt
The file /test_enc_version_affected_user1/files/world.txt is: OK
", $output);
Expand Down Expand Up @@ -219,15 +220,15 @@ public function testEncryptedVersionLessThanOriginalValue() {
Increment the encrypted version to 5
Increment the encrypted version to 6
The file /test_enc_version_affected_user1/files/hello.txt is: OK
Fixed the file /test_enc_version_affected_user1/files/hello.txt with version 6
Fixed the file: /test_enc_version_affected_user1/files/hello.txt with version 6
Verifying the content of file /test_enc_version_affected_user1/files/world.txt
Attempting to fix the path: /test_enc_version_affected_user1/files/world.txt
Increment the encrypted version to 2
Increment the encrypted version to 3
Increment the encrypted version to 4
Increment the encrypted version to 5
The file /test_enc_version_affected_user1/files/world.txt is: OK
Fixed the file /test_enc_version_affected_user1/files/world.txt with version 5
Fixed the file: /test_enc_version_affected_user1/files/world.txt with version 5
", $output);
/**
* We need to add ob_start at the end because if not done, it would be considered as a risky test.
Expand Down Expand Up @@ -293,7 +294,7 @@ public function testEncryptedVersionGreaterThanOriginalValue() {
Decrement the encrypted version to 10
Decrement the encrypted version to 9
The file /test_enc_version_affected_user1/files/hello.txt is: OK
Fixed the file /test_enc_version_affected_user1/files/hello.txt with version 9
Fixed the file: /test_enc_version_affected_user1/files/hello.txt with version 9
Verifying the content of file /test_enc_version_affected_user1/files/world.txt
Attempting to fix the path: /test_enc_version_affected_user1/files/world.txt
Decrement the encrypted version to 14
Expand All @@ -303,7 +304,7 @@ public function testEncryptedVersionGreaterThanOriginalValue() {
Decrement the encrypted version to 10
Decrement the encrypted version to 9
The file /test_enc_version_affected_user1/files/world.txt is: OK
Fixed the file /test_enc_version_affected_user1/files/world.txt with version 9
Fixed the file: /test_enc_version_affected_user1/files/world.txt with version 9
", $output);
/**
* We need to add ob_start at the end because if not done, it would be considered as a risky test.
Expand Down

0 comments on commit c530242

Please sign in to comment.