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

fix for share folder on external storage

parent ae0f37e9
No related branches found
No related tags found
No related merge requests found
...@@ -327,6 +327,13 @@ class Hooks { ...@@ -327,6 +327,13 @@ class Hooks {
// if a folder was shared, get a list of all (sub-)folders // if a folder was shared, get a list of all (sub-)folders
if ($params['itemType'] === 'folder') { 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); $allFiles = $util->getAllFiles($path);
} else { } else {
$allFiles = array($path); $allFiles = array($path);
...@@ -403,6 +410,12 @@ class Hooks { ...@@ -403,6 +410,12 @@ class Hooks {
// if we unshare a folder we need a list of all (sub-)files // if we unshare a folder we need a list of all (sub-)files
if ( $params['itemType'] === 'folder' ) { 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 ); $allFiles = $util->getAllFiles( $path );
} else { } else {
......
...@@ -1199,7 +1199,7 @@ class Util { ...@@ -1199,7 +1199,7 @@ class Util {
$result = array(); $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 // handling for re shared folders
$path_split = explode('/', $dir); $path_split = explode('/', $dir);
...@@ -1531,4 +1531,22 @@ class Util { ...@@ -1531,4 +1531,22 @@ class Util {
$this->recoverAllFiles('/', $privateKey); $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;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment