summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-12-13 14:02:49 +0100
committerGitHub <noreply@github.com>2016-12-13 14:02:49 +0100
commitedd01e3ce4809e040c4a75432c531be6a80022d2 (patch)
tree0f222c5068f52be220036817ccd53e72a4d09303 /apps/files_sharing
parent3b3ab256a51339c0c7278274a4ba7d4835049bd9 (diff)
parent14a561ddad8bbd6ae1d524a49c70a7926c06310f (diff)
downloadnextcloud-server-edd01e3ce4809e040c4a75432c531be6a80022d2.tar.gz
nextcloud-server-edd01e3ce4809e040c4a75432c531be6a80022d2.zip
Merge pull request #2637 from nextcloud/mount-cache-storageid
also compare storage ids when checking for changed mounts
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/SharedMount.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index 5436f476f1a..b7fb96b711b 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -130,12 +130,12 @@ class SharedMount extends MountPoint implements MoveableMount {
*/
private function generateUniqueTarget($path, $view, array $mountpoints) {
$pathinfo = pathinfo($path);
- $ext = (isset($pathinfo['extension'])) ? '.'.$pathinfo['extension'] : '';
+ $ext = (isset($pathinfo['extension'])) ? '.' . $pathinfo['extension'] : '';
$name = $pathinfo['filename'];
$dir = $pathinfo['dirname'];
// Helper function to find existing mount points
- $mountpointExists = function($path) use ($mountpoints) {
+ $mountpointExists = function ($path) use ($mountpoints) {
foreach ($mountpoints as $mountpoint) {
if ($mountpoint->getShare()->getTarget() === $path) {
return true;
@@ -146,7 +146,7 @@ class SharedMount extends MountPoint implements MoveableMount {
$i = 2;
while ($view->file_exists($path) || $mountpointExists($path)) {
- $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext);
+ $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext);
$i++;
}
@@ -240,18 +240,22 @@ class SharedMount extends MountPoint implements MoveableMount {
* @return int
*/
public function getNumericStorageId() {
- $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
-
- $query = $builder->select('storage')
- ->from('filecache')
- ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId())));
-
- $result = $query->execute();
- $row = $result->fetch();
- $result->closeCursor();
- if ($row) {
- return $row['storage'];
+ if (!is_null($this->getShare()->getNodeCacheEntry())) {
+ return $this->getShare()->getNodeCacheEntry()->getStorageId();
+ } else {
+ $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+
+ $query = $builder->select('storage')
+ ->from('filecache')
+ ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId())));
+
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+ if ($row) {
+ return $row['storage'];
+ }
+ return -1;
}
- return -1;
}
}