summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-12-06 15:14:48 +0100
committerGitHub <noreply@github.com>2017-12-06 15:14:48 +0100
commitc32cb6b4b79baeb86f5702d20db0d4b6ed874d86 (patch)
tree6b05409b81f1d481177fb5c2a81eeb6c40f4aa56 /apps/files_sharing
parentde8fefeb18cd72a3a25c9fde431c21abdfa015aa (diff)
parentc87d6892531c75c7d34bd4493f4569c8ab828c0e (diff)
downloadnextcloud-server-c32cb6b4b79baeb86f5702d20db0d4b6ed874d86.tar.gz
nextcloud-server-c32cb6b4b79baeb86f5702d20db0d4b6ed874d86.zip
Merge pull request #7385 from nextcloud/shared-delay-root
delay calculating the shared cache root until it's used
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Cache.php44
1 files changed, 27 insertions, 17 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index e08da0d73e5..352001ecbd4 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -64,23 +64,29 @@ class Cache extends CacheJail {
$this->sourceRootInfo = $sourceRootInfo;
$this->numericId = $sourceRootInfo->getStorageId();
- $absoluteRoot = $this->sourceRootInfo->getPath();
-
- // the sourceRootInfo path is the absolute path of the folder in the "real" storage
- // in the case where a folder is shared from a Jail we need to ensure that the share Jail
- // has it's root set relative to the source Jail
- $currentStorage = $storage->getSourceStorage();
- if ($currentStorage->instanceOfStorage(Jail::class)) {
- /** @var Jail $currentStorage */
- $absoluteRoot = $currentStorage->getJailedPath($absoluteRoot);
- }
-
parent::__construct(
null,
- $absoluteRoot
+ null
);
}
+ protected function getRoot() {
+ if (is_null($this->root)) {
+ $absoluteRoot = $this->sourceRootInfo->getPath();
+
+ // the sourceRootInfo path is the absolute path of the folder in the "real" storage
+ // in the case where a folder is shared from a Jail we need to ensure that the share Jail
+ // has it's root set relative to the source Jail
+ $currentStorage = $this->storage->getSourceStorage();
+ if ($currentStorage->instanceOfStorage(Jail::class)) {
+ /** @var Jail $currentStorage */
+ $absoluteRoot = $currentStorage->getJailedPath($absoluteRoot);
+ }
+ $this->root = $absoluteRoot;
+ }
+ return $this->root;
+ }
+
public function getCache() {
if (is_null($this->cache)) {
$sourceStorage = $this->storage->getSourceStorage();
@@ -104,7 +110,7 @@ class Cache extends CacheJail {
public function get($file) {
if ($this->rootUnchanged && ($file === '' || $file === $this->sourceRootInfo->getId())) {
- return $this->formatCacheEntry(clone $this->sourceRootInfo);
+ return $this->formatCacheEntry(clone $this->sourceRootInfo, '');
}
return parent::get($file);
}
@@ -129,16 +135,20 @@ class Cache extends CacheJail {
return parent::moveFromCache($sourceCache, $sourcePath, $targetPath);
}
- protected function formatCacheEntry($entry) {
- $path = isset($entry['path']) ? $entry['path'] : '';
- $entry = parent::formatCacheEntry($entry);
+ protected function formatCacheEntry($entry, $path = null) {
+ if (is_null($path)) {
+ $path = isset($entry['path']) ? $entry['path'] : '';
+ $entry['path'] = $this->getJailedPath($path);
+ } else {
+ $entry['path'] = $path;
+ }
$sharePermissions = $this->storage->getPermissions($path);
if (isset($entry['permissions'])) {
$entry['permissions'] &= $sharePermissions;
} else {
$entry['permissions'] = $sharePermissions;
}
- $entry['uid_owner'] = $this->storage->getOwner($path);
+ $entry['uid_owner'] = $this->storage->getOwner('');
$entry['displayname_owner'] = $this->getOwnerDisplayName();
if ($path === '') {
$entry['is_share_mount_point'] = true;