From 7dab284135763ff6b85cd2c89766ea89f43eb180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 28 Jul 2016 15:48:46 +0200 Subject: [PATCH 1/2] Take from https://github.com/nextcloud/server/pull/608/commits/351cab6bce41b53f9efd4ba9aed4e7435f843691 - THX @schiessle --- lib/private/Encryption/DecryptAll.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php index f55af7247ef3..a3f324822c0c 100644 --- a/lib/private/Encryption/DecryptAll.php +++ b/lib/private/Encryption/DecryptAll.php @@ -209,6 +209,10 @@ protected function decryptUsersFiles($uid, ProgressBar $progress, $userCount) { while ($root = array_pop($directories)) { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { + // only decrypt files owned by the user + if($file->getStorage()->instanceOfStorage('OC\Files\Storage\Shared')) { + continue; + } $path = $root . '/' . $file['name']; if ($this->rootView->is_dir($path)) { $directories[] = $path; From 8aaf06ce68026563b2e7ccad5ffaa3b122c4204a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 28 Jul 2016 15:49:38 +0200 Subject: [PATCH 2/2] Fix unit tests --- tests/lib/Encryption/DecryptAllTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index d7cf2fb7baf7..3f7cb59c8f48 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -239,6 +239,10 @@ public function dataTestDecryptAllUsersFiles() { } public function testDecryptUsersFiles() { + $storage = $this->getMockBuilder('OC\Files\Storage\Shared') + ->disableOriginalConstructor() + ->getMock(); + /** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject $instance */ $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') ->setConstructorArgs( @@ -254,15 +258,15 @@ public function testDecryptUsersFiles() { $this->view->expects($this->at(0))->method('getDirectoryContent') ->with('/user1/files')->willReturn( [ - new FileInfo('path', null, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), - new FileInfo('path', null, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null) + new FileInfo('path', $storage, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), + new FileInfo('path', $storage, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null) ] ); $this->view->expects($this->at(3))->method('getDirectoryContent') ->with('/user1/files/foo')->willReturn( [ - new FileInfo('path', null, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null) + new FileInfo('path', $storage, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null) ] );