Skip to content
Snippets Groups Projects
Commit efd62946 authored by Florin Peter's avatar Florin Peter
Browse files

changes after review

parent c398fc59
No related branches found
No related tags found
No related merge requests found
...@@ -1422,6 +1422,7 @@ class Util { ...@@ -1422,6 +1422,7 @@ class Util {
} else { } else {
$session = new \OCA\Encryption\Session(new \OC_FilesystemView('/')); $session = new \OCA\Encryption\Session(new \OC_FilesystemView('/'));
$sharingEnabled = \OCP\Share::isEnabled(); $sharingEnabled = \OCP\Share::isEnabled();
// remove '.key' extension from path e.g. 'file.txt.key' to 'file.txt'
$file = substr($filePath, 0, -4); $file = substr($filePath, 0, -4);
$usersSharing = $this->getSharingUsersArray($sharingEnabled, $file); $usersSharing = $this->getSharingUsersArray($sharingEnabled, $file);
$this->setSharedFileKeyfiles($session, $usersSharing, $file); $this->setSharedFileKeyfiles($session, $usersSharing, $file);
...@@ -1440,6 +1441,7 @@ class Util { ...@@ -1440,6 +1441,7 @@ class Util {
if ($item['type'] === 'dir') { if ($item['type'] === 'dir') {
$this->removeRecoveryKeys($filePath . '/'); $this->removeRecoveryKeys($filePath . '/');
} else { } else {
// remove '.key' extension from path e.g. 'file.txt.key' to 'file.txt'
$file = substr($filePath, 0, -4); $file = substr($filePath, 0, -4);
$this->view->unlink($this->shareKeysPath . '/' . $file . '.' . $this->recoveryKeyId . '.shareKey'); $this->view->unlink($this->shareKeysPath . '/' . $file . '.' . $this->recoveryKeyId . '.shareKey');
} }
...@@ -1502,10 +1504,12 @@ class Util { ...@@ -1502,10 +1504,12 @@ class Util {
private function recoverAllFiles($path, $privateKey) { private function recoverAllFiles($path, $privateKey) {
$dirContent = $this->view->getDirectoryContent($this->keyfilesPath . $path); $dirContent = $this->view->getDirectoryContent($this->keyfilesPath . $path);
foreach ($dirContent as $item) { foreach ($dirContent as $item) {
$filePath = substr($item['path'], 25); // get relative path from files_encryption/keyfiles
$filePath = substr($item['path'], strlen('files_encryption/keyfiles'));
if ($item['type'] === 'dir') { if ($item['type'] === 'dir') {
$this->recoverAllFiles($filePath . '/', $privateKey); $this->recoverAllFiles($filePath . '/', $privateKey);
} else { } else {
// remove '.key' extension from path e.g. 'file.txt.key' to 'file.txt'
$file = substr($filePath, 0, -4); $file = substr($filePath, 0, -4);
$this->recoverFile($file, $privateKey); $this->recoverFile($file, $privateKey);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment