skip shared files, if files get decrypted only for a specific user we shouldn't touch files owned by a different user.

This commit is contained in:
Bjoern Schiessle 2016-07-27 15:11:48 +02:00
parent 318d68a9a9
commit 351cab6bce
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
2 changed files with 18 additions and 3 deletions

View File

@ -210,6 +210,10 @@ class DecryptAll {
while ($root = array_pop($directories)) { while ($root = array_pop($directories)) {
$content = $this->rootView->getDirectoryContent($root); $content = $this->rootView->getDirectoryContent($root);
foreach ($content as $file) { foreach ($content as $file) {
// only decrypt files owned by the user
if($file->getStorage()->instanceOfStorage('OC\Files\Storage\Shared')) {
continue;
}
$path = $root . '/' . $file['name']; $path = $root . '/' . $file['name'];
if ($this->rootView->is_dir($path)) { if ($this->rootView->is_dir($path)) {
$directories[] = $path; $directories[] = $path;

View File

@ -251,18 +251,29 @@ class DecryptAllTest extends TestCase {
->setMethods(['decryptFile']) ->setMethods(['decryptFile'])
->getMock(); ->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') $this->view->expects($this->at(0))->method('getDirectoryContent')
->with('/user1/files')->willReturn( ->with('/user1/files')->willReturn(
[ [
new FileInfo('path', null, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), new FileInfo('path', $storage, 'intPath', ['name' => 'foo', 'type'=>'dir'], null),
new FileInfo('path', null, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], 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') $this->view->expects($this->at(3))->method('getDirectoryContent')
->with('/user1/files/foo')->willReturn( ->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)
] ]
); );