summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2015-11-18 21:49:10 +0100
committerRobin Appelman <robin@icewind.nl>2015-11-18 21:49:10 +0100
commitda5285dc23dc88d8f570409a8d7ed1296b95f407 (patch)
tree94678263c654d3b34e8706c5af6cd40d5a188eee
parentde30b2173dccd803ce04b832174eefd5d151df3d (diff)
parent71b86c0ed4adc0a774e852338f1cd1fb192b7569 (diff)
downloadnextcloud-server-da5285dc23dc88d8f570409a8d7ed1296b95f407.tar.gz
nextcloud-server-da5285dc23dc88d8f570409a8d7ed1296b95f407.zip
Merge pull request #20584 from owncloud/fileinfo-owner-external-share
Fix getOwner for external shares
-rw-r--r--apps/files_sharing/lib/external/storage.php7
-rw-r--r--lib/private/files/view.php25
2 files changed, 26 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php
index 270d8b6d1b8..2a0d827e064 100644
--- a/apps/files_sharing/lib/external/storage.php
+++ b/apps/files_sharing/lib/external/storage.php
@@ -250,7 +250,7 @@ class Storage extends DAV implements ISharedStorage {
$response = $client->post($url, ['body' => ['password' => $password]]);
} catch (\GuzzleHttp\Exception\RequestException $e) {
if ($e->getCode() === 401 || $e->getCode() === 403) {
- throw new ForbiddenException();
+ throw new ForbiddenException();
}
// throw this to be on the safe side: the share will still be visible
// in the UI in case the failure is intermittent, and the user will
@@ -260,4 +260,9 @@ class Storage extends DAV implements ISharedStorage {
return json_decode($response->getBody(), true);
}
+
+ public function getOwner($path) {
+ list(, $remote) = explode('://', $this->remote, 2);
+ return $this->remoteUser . '@' . $remote;
+ }
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 7dd83588ec6..cee4b182425 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -46,11 +46,13 @@ namespace OC\Files;
use Icewind\Streams\CallbackWrapper;
use OC\Files\Cache\Updater;
use OC\Files\Mount\MoveableMount;
+use OC\User\User;
use OCP\Files\FileNameTooLongException;
use OCP\Files\InvalidCharacterInPathException;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\ReservedWordException;
+use OCP\IUser;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
@@ -687,14 +689,14 @@ class View {
} else {
$result = false;
}
- // moving a file/folder within the same mount point
+ // moving a file/folder within the same mount point
} elseif ($storage1 == $storage2) {
if ($storage1) {
$result = $storage1->rename($internalPath1, $internalPath2);
} else {
$result = false;
}
- // moving a file/folder between storages (from $storage1 to $storage2)
+ // moving a file/folder between storages (from $storage1 to $storage2)
} else {
$result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
}
@@ -1164,6 +1166,19 @@ class View {
}
/**
+ * @param string $ownerId
+ * @return \OC\User\User
+ */
+ private function getUserObjectForOwner($ownerId) {
+ $owner = \OC::$server->getUserManager()->get($ownerId);
+ if ($owner instanceof IUser) {
+ return $owner;
+ } else {
+ return new User($ownerId, null);
+ }
+ }
+
+ /**
* get the filesystem info
*
* @param string $path
@@ -1250,7 +1265,7 @@ class View {
$data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
}
- $owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
+ $owner = $this->getUserObjectForOwner($storage->getOwner($internalPath));
return new FileInfo($path, $storage, $internalPath, $data, $mount, $owner);
}
@@ -1317,7 +1332,7 @@ class View {
if (\OCP\Util::isSharingDisabledForUser()) {
$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
}
- $owner = \OC::$server->getUserManager()->get($storage->getOwner($content['path']));
+ $owner = $this->getUserObjectForOwner($storage->getOwner($content['path']));
$files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
}
@@ -1387,7 +1402,7 @@ class View {
$rootEntry['permissions'] = $rootEntry['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
}
- $owner = \OC::$server->getUserManager()->get($subStorage->getOwner(''));
+ $owner = $this->getUserObjectForOwner($subStorage->getOwner(''));
$files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
}
}