Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/share/file.php23
-rw-r--r--apps/files_sharing/lib/sharedstorage.php20
-rw-r--r--lib/files/mount.php26
-rw-r--r--lib/files/view.php2
-rw-r--r--lib/public/share.php2
-rw-r--r--tests/lib/files/mount.php8
6 files changed, 62 insertions, 19 deletions
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 0aeb763d89a..fa43e87b49e 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -73,7 +73,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
if ($format == self::FORMAT_SHARED_STORAGE) {
// Only 1 item should come through for this format call
return array(
+ 'parent' => $items[key($items)]['parent'],
'path' => $items[key($items)]['path'],
+ 'storage' => $items[key($items)]['storage'],
'permissions' => $items[key($items)]['permissions'],
'uid_owner' => $items[key($items)]['uid_owner']
);
@@ -139,13 +141,28 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
$source = \OCP\Share::getItemSharedWith('folder', $folder, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
if ($source) {
$source['path'] = $source['path'].substr($target, strlen($folder));
- return $source;
}
} else {
$source = \OCP\Share::getItemSharedWith('file', $target, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
- if ($source) {
- return $source;
+ }
+ if ($source) {
+ if (isset($source['parent'])) {
+ $parent = $source['parent'];
+ while (isset($parent)) {
+ $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
+ $item = $query->execute(array($parent))->fetchRow();
+ if (isset($item['parent'])) {
+ $parent = $item['parent'];
+ } else {
+ $fileOwner = $item['uid_owner'];
+ break;
+ }
+ }
+ } else {
+ $fileOwner = $source['uid_owner'];
}
+ $source['fileOwner'] = $fileOwner;
+ return $source;
}
\OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::ERROR);
return false;
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 5a9864b64ba..be0e59e6732 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -45,11 +45,7 @@ class Shared extends \OC\Files\Storage\Common {
*/
private function getFile($target) {
if (!isset($this->files[$target])) {
- $source = \OC_Share_Backend_File::getSource($target);
- if ($source) {
- $source['path'] = '/'.$source['uid_owner'].'/'.$source['path'];
- }
- $this->files[$target] = $source;
+ $this->files[$target] = \OC_Share_Backend_File::getSource($target);
}
return $this->files[$target];
}
@@ -62,8 +58,16 @@ class Shared extends \OC\Files\Storage\Common {
private function getSourcePath($target) {
$source = $this->getFile($target);
if ($source) {
- \OC\Files\Filesystem::initMountPoints($source['uid_owner']);
- return $source['path'];
+ if (!isset($source['fullPath'])) {
+ \OC\Files\Filesystem::initMountPoints($source['fileOwner']);
+ $mount = \OC\Files\Mount::findByNumericId($source['storage']);
+ if ($mount) {
+ $this->files[$target]['fullPath'] = $mount->getMountPoint().$source['path'];
+ } else {
+ $this->files[$target]['fullPath'] = false;
+ }
+ }
+ return $this->files[$target]['fullPath'];
}
return false;
}
@@ -430,7 +434,7 @@ class Shared extends \OC\Files\Storage\Common {
}
$source = $this->getFile($path);
if ($source) {
- return $source['uid_owner'];
+ return $source['fileOwner'];
}
return false;
}
diff --git a/lib/files/mount.php b/lib/files/mount.php
index 6e99d8eabb4..1c9382d78e7 100644
--- a/lib/files/mount.php
+++ b/lib/files/mount.php
@@ -176,10 +176,12 @@ class Mount {
}
/**
+ * Find mounts by storage id
+ *
* @param string $id
- * @return \OC\Files\Storage\Storage[]
+ * @return Mount[]
*/
- public static function findById($id) {
+ public static function findByStorageId($id) {
if (strlen($id) > 64) {
$id = md5($id);
}
@@ -191,4 +193,24 @@ class Mount {
}
return $result;
}
+
+ /**
+ * Find mounts by numeric storage id
+ *
+ * @param string $id
+ * @return Mount
+ */
+ public static function findByNumericId($id) {
+ $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?');
+ $result = $query->execute(array($id))->fetchOne();
+ if ($result) {
+ $id = $result;
+ foreach (self::$mounts as $mount) {
+ if ($mount->getStorageId() === $id) {
+ return $mount;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/lib/files/view.php b/lib/files/view.php
index 3e2cb080e1d..4ed3234552e 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -960,7 +960,7 @@ class View {
*/
public function getPath($id) {
list($storage, $internalPath) = Cache\Cache::getById($id);
- $mounts = Mount::findById($storage);
+ $mounts = Mount::findByStorageId($storage);
foreach ($mounts as $mount) {
/**
* @var \OC\Files\Mount $mount
diff --git a/lib/public/share.php b/lib/public/share.php
index 8146a23f360..59f41a9bfd6 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -786,7 +786,7 @@ class Share {
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`,
`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,
- `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`';
+ `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`';
}
} else {
$select = '*';
diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php
index 4e6aaf0679b..6a5c025b0e1 100644
--- a/tests/lib/files/mount.php
+++ b/tests/lib/files/mount.php
@@ -42,7 +42,7 @@ class Mount extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array($mount), \OC\Files\Mount::findById($id));
$mount2 = new \OC\Files\Mount($storage, '/foo/bar');
- $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findById($id));
+ $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findByStorageId($id));
}
public function testLong() {
@@ -51,8 +51,8 @@ class Mount extends \PHPUnit_Framework_TestCase {
$id = $mount->getStorageId();
$storageId = $storage->getId();
- $this->assertEquals(array($mount), \OC\Files\Mount::findById($id));
- $this->assertEquals(array($mount), \OC\Files\Mount::findById($storageId));
- $this->assertEquals(array($mount), \OC\Files\Mount::findById(md5($storageId)));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($storageId));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId(md5($storageId)));
}
}