]> source.dussan.org Git - nextcloud-server.git/commitdiff
skip shared files, if files get decrypted only for a specific user we shouldn't touch... 1345/head
authorBjoern Schiessle <bjoern@schiessle.org>
Wed, 27 Jul 2016 13:11:48 +0000 (15:11 +0200)
committerBjoern Schiessle <bjoern@schiessle.org>
Fri, 9 Sep 2016 12:55:46 +0000 (14:55 +0200)
lib/private/Encryption/DecryptAll.php
tests/lib/Encryption/DecryptAllTest.php

index 6e309b5c8926d84baf216a4633050c2326b98282..b84395b9e17e932e4b73750b3a7c237cee6390c3 100644 (file)
@@ -210,6 +210,10 @@ class DecryptAll {
                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;
index d7cf2fb7baf73d8e6020aff5313fcbc9ab57f56b..ed86b743c3b71d16a28905c9e758d15692082ad7 100644 (file)
@@ -251,18 +251,29 @@ class DecryptAllTest extends TestCase {
                        ->setMethods(['decryptFile'])
                        ->getMock();
 
+               $storage = $this->getMockBuilder('OCP\Files\Storage')
+                       ->disableOriginalConstructor()->getMock();
+
+
+               $sharedStorage = $this->getMockBuilder('OCP\Files\Storage')
+                       ->disableOriginalConstructor()->getMock();
+
+               $sharedStorage->expects($this->once())->method('instanceOfStorage')
+                       ->with('OC\Files\Storage\Shared')->willReturn(true);
+
                $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),
+                                       new FileInfo('path', $sharedStorage, 'intPath', ['name' => 'shared', '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)
                                ]
                        );