summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-12-10 14:14:54 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-11 11:40:58 +0100
commit300eb54c871cfe48165ee32ecdc5067226aa0b7b (patch)
tree4ed24210cce449f439ec1c30e5dced7f9e71b1e3 /lib
parentfd2e1086c69e2c4c237e8ceab06f8948983bbb17 (diff)
downloadnextcloud-server-300eb54c871cfe48165ee32ecdc5067226aa0b7b.tar.gz
nextcloud-server-300eb54c871cfe48165ee32ecdc5067226aa0b7b.zip
de-deplicate getUidAndFilename
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/view.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 6bc1ac46ef3..19197950988 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -44,7 +44,6 @@
namespace OC\Files;
use Icewind\Streams\CallbackWrapper;
-use OC\Files\Cache\Updater;
use OC\Files\Mount\MoveableMount;
use OC\Files\Storage\Storage;
use OC\User\User;
@@ -2017,4 +2016,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];
+ }
}