summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/hooks/hooks.php15
-rw-r--r--apps/files_encryption/lib/util.php26
2 files changed, 36 insertions, 5 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 0ef796dbaef..dd51a75f8f8 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -327,6 +327,13 @@ class Hooks {
// if a folder was shared, get a list of all (sub-)folders
if ($params['itemType'] === 'folder') {
+
+ // get the path including mount point only if not a shared folder
+ if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {
+ // get path including the the storage mount point
+ $path = $util->getPathWithMountPoint($params['itemSource']);
+ }
+
$allFiles = $util->getAllFiles($path);
} else {
$allFiles = array($path);
@@ -402,7 +409,13 @@ class Hooks {
// if we unshare a folder we need a list of all (sub-)files
if ( $params['itemType'] === 'folder' ) {
-
+
+ // get the path including mount point only if not a shared folder
+ if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {
+ // get path including the the storage mount point
+ $path = $util->getPathWithMountPoint($params['itemSource']);
+ }
+
$allFiles = $util->getAllFiles( $path );
} else {
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 6ffe31c9bb4..218e58c3402 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -541,7 +541,7 @@ class Util {
// we only need 24 byte from the last chunk
$data = '';
$handle = $this->view->fopen($path, 'r');
- if (!fseek($handle, -24, SEEK_END)) {
+ if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) {
$data = fgets($handle);
}
@@ -1028,7 +1028,7 @@ class Util {
if ($sharingEnabled) {
// Find out who, if anyone, is sharing the file
- $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true, true, true);
+ $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true);
$userIds = $result['users'];
if ($result['public']) {
$userIds[] = $this->publicShareKeyId;
@@ -1199,7 +1199,7 @@ class Util {
$result = array();
- $content = $this->view->getDirectoryContent($this->userFilesDir . $dir);
+ $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath($this->userFilesDir . '/' . $dir));
// handling for re shared folders
$path_split = explode('/', $dir);
@@ -1457,7 +1457,7 @@ class Util {
// Find out who, if anyone, is sharing the file
if ($sharingEnabled) {
- $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true, true, true);
+ $result = \OCP\Share::getUsersSharingFile($file, $this->userId, true);
$userIds = $result['users'];
$userIds[] = $this->recoveryKeyId;
if ($result['public']) {
@@ -1531,4 +1531,22 @@ class Util {
$this->recoverAllFiles('/', $privateKey);
}
+ /**
+ * Get the path including the storage mount point
+ * @param int $id
+ * @return string the path including the mount point like AmazonS3/folder/file.txt
+ */
+ public function getPathWithMountPoint($id) {
+ list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
+ $mount = \OC\Files\Filesystem::getMountByStorageId($storage);
+ $mountPoint = $mount[0]->getMountPoint();
+ $path = \OC\Files\Filesystem::normalizePath($mountPoint.'/'.$internalPath);
+
+ // reformat the path to be relative e.g. /user/files/folder becomes /folder/
+ $pathSplit = explode( '/', $path );
+ $relativePath = implode( '/', array_slice( $pathSplit, 3 ) );
+
+ return $relativePath;
+ }
+
}