summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-07-05 11:56:02 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-07-05 11:56:02 -0400
commit9deab8302f4c41daed3db6f3b470480b2710c502 (patch)
treea86a04cb27b08940f91ba8f8c5ed5682f9f93730
parent607f1a2738911ace1026c6bc14aa28481a898897 (diff)
downloadnextcloud-server-9deab8302f4c41daed3db6f3b470480b2710c502.tar.gz
nextcloud-server-9deab8302f4c41daed3db6f3b470480b2710c502.zip
Fix bugs in getSource() and implement new target path standard
-rw-r--r--apps/files_sharing/lib_share.php4
-rw-r--r--apps/files_sharing/sharedstorage.php19
-rw-r--r--lib/filesystem.php10
3 files changed, 18 insertions, 15 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index b03720b7537..77b0bc4a70c 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -82,6 +82,8 @@ class OC_SHARE {
* @return source path
*/
public static function getSource($target) {
+ // Remove any trailing '/'
+ $target = rtrim($target, "/");
$query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1");
$result = $query->execute(array($target, $_SESSION['user_id']))->fetchAll();
if (count($result) > 0) {
@@ -89,7 +91,7 @@ class OC_SHARE {
} else {
// Check if the parent directory of this target is shared
$parentDir = dirname($target);
- if ($parentDir != ".") {
+ if ($parentDir != "" && $parentDir != "/" && $parentDir != ".") {
$result = OC_SHARE::getSource($parentDir);
if ($result) {
return $result."/".basename($target);
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index e17685a09e7..0303cce79fb 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -43,22 +43,13 @@ class OC_FILESTORAGE_SHARED {
}
public function getSource($target) {
- if ($target == "") {
- return false;
- } elseif (array_key_exists($target, $this->sourcePaths)) {
+ $target = OC_FILESYSTEM::getStorageMountPoint($this).$target;
+ if (array_key_exists($target, $this->sourcePaths)) {
return $this->sourcePaths[$target];
} else {
- $parentDir = dirname($target);
- if ($parentDir != ".") {
- $source = $this->getSource($parentDir);
- return $source."/".basename($target);
- } else {
- $source = OC_SHARE::getSource($target);
- if ($source) {
- $this->sourcePaths[$target] = $source;
- }
- return $source;
- }
+ $source = OC_SHARE::getSource($target);
+ $this->sourcePaths[$target] = $source;
+ return $source;
}
}
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 4116cb93164..c7e2070fa0a 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -214,6 +214,16 @@ class OC_FILESYSTEM{
}
return $foundMountPoint;
}
+
+ /**
+ * get the mountpoint of the storage object
+ * @param OC_FILESTORAGE storage
+ * @return string
+ */
+ static public function getStorageMountPoint($storage){
+ return array_search($storage, self::$storages);
+ }
+
/**
* return the path to a local version of the file
* we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed