diff options
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r-- | lib/private/files/view.php | 33 |
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]; + } } |