summaryrefslogtreecommitdiffstats
path: root/lib/private/files
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-15 13:31:56 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-15 13:31:56 +0100
commit6824704699a87dbccabe61319610141e7411b90e (patch)
tree5030163c53cbb91f7ea518b4046666148d504291 /lib/private/files
parent41106c1967cb7cbee20dd56666d9605eabdc4460 (diff)
parent94200b682cacbbb5fe673fad64ec5bf1d12f34fc (diff)
downloadnextcloud-server-6824704699a87dbccabe61319610141e7411b90e.tar.gz
nextcloud-server-6824704699a87dbccabe61319610141e7411b90e.zip
Merge pull request #21117 from owncloud/owner-file-exists
Only return an owner if the file exists + improved getUidAndFilename
Diffstat (limited to 'lib/private/files')
-rw-r--r--lib/private/files/view.php33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 55b8da165e1..d4cc24ae0f5 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1573,10 +1573,15 @@ class View {
* Get the owner for a file or folder
*
* @param string $path
- * @return string
+ * @return string the user id of the owner
+ * @throws NotFoundException
*/
public function getOwner($path) {
- return $this->basicOperation('getOwner', $path);
+ $info = $this->getFileInfo($path);
+ if (!$info) {
+ throw new NotFoundException($path . ' not found while trying to get owner');
+ }
+ return $info->getOwner()->getUID();
}
/**
@@ -2021,4 +2026,28 @@ class View {
}
return '';
}
+
+ /**
+ * @param string $filename
+ * @return array
+ * @throws \OC\User\NoUserException
+ * @throws NotFoundException
+ */
+ public function getUidAndFilename($filename) {
+ $info = $this->getFileInfo($filename);
+ if (!$info instanceof \OCP\Files\FileInfo) {
+ throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
+ }
+ $uid = $info->getOwner()->getUID();
+ if ($uid != \OCP\User::getUser()) {
+ Filesystem::initMountPoints($uid);
+ $ownerView = new View('/' . $uid . '/files');
+ try {
+ $filename = $ownerView->getPath($info['fileid']);
+ } catch (NotFoundException $e) {
+ throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
+ }
+ }
+ return [$uid, $filename];
+ }
}