summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-31 10:12:03 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-31 10:12:03 +0200
commita441220f2439b00e39edb74bdace693b729b11ac (patch)
tree80b753cd1815945213ea883853b9e0e4d8a9d6a7
parent3361cdf0cc697fc3c96def63ee762360a69db783 (diff)
parentb15babd061c811e26093624ac4140c88a9e5ebcd (diff)
downloadnextcloud-server-a441220f2439b00e39edb74bdace693b729b11ac.tar.gz
nextcloud-server-a441220f2439b00e39edb74bdace693b729b11ac.zip
Merge pull request #24628 from owncloud/decryptall-checkifneedsprocessing
[decrypt_all] Check if file needs to decrypted or not for speed up large oc setups.
-rw-r--r--lib/private/Encryption/DecryptAll.php12
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php7
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php
index 973036fe14d..8676bc09575 100644
--- a/lib/private/Encryption/DecryptAll.php
+++ b/lib/private/Encryption/DecryptAll.php
@@ -133,6 +133,7 @@ class DecryptAll {
/**
* iterate over all user and encrypt their files
+ *
* @param string $user which users files should be decrypted, default = all users
*/
protected function decryptAllUsersFiles($user = '') {
@@ -200,9 +201,9 @@ class DecryptAll {
$this->setupUserFS($uid);
$directories = array();
- $directories[] = '/' . $uid . '/files';
+ $directories[] = '/' . $uid . '/files';
- while($root = array_pop($directories)) {
+ while ($root = array_pop($directories)) {
$content = $this->rootView->getDirectoryContent($root);
foreach ($content as $file) {
$path = $root . '/' . $file['name'];
@@ -213,9 +214,14 @@ class DecryptAll {
try {
$progress->setMessage("decrypt files for user $userCount: $path");
$progress->advance();
- if ($this->decryptFile($path) === false) {
+ if ($file->isEncrypted() === false) {
$progress->setMessage("decrypt files for user $userCount: $path (already decrypted)");
$progress->advance();
+ } else {
+ if ($this->decryptFile($path) === false) {
+ $progress->setMessage("decrypt files for user $userCount: $path (already decrypted)");
+ $progress->advance();
+ }
}
} catch (\Exception $e) {
if (isset($this->failed[$uid])) {
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 85fbe3e0ed9..ffcbbc74a99 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -26,6 +26,7 @@ namespace Test\Encryption;
use OC\Encryption\DecryptAll;
use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Encryption\Manager;
+use OC\Files\FileInfo;
use OC\Files\View;
use OCP\IUserManager;
use Test\TestCase;
@@ -242,15 +243,15 @@ class DecryptAllTest extends TestCase {
$this->view->expects($this->at(0))->method('getDirectoryContent')
->with('/user1/files')->willReturn(
[
- ['name' => 'foo', 'type'=>'dir'],
- ['name' => 'bar', 'type'=>'file'],
+ new FileInfo('path', null, 'intPath', ['name' => 'foo', 'type'=>'dir'], null),
+ new FileInfo('path', null, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null)
]
);
$this->view->expects($this->at(3))->method('getDirectoryContent')
->with('/user1/files/foo')->willReturn(
[
- ['name' => 'subfile', 'type'=>'file']
+ new FileInfo('path', null, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null)
]
);