diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 2452f4c6ae3ef5f902fd922bc32b85dc10abe372..0ff76e60580817c79b6e0068508d25a6c0de16d5 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1028,7 +1028,7 @@ class Util {
 		if ($sharingEnabled) {
 
 			// Find out who, if anyone, is sharing the file
-			$result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true, true, true);
+			$result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, true);
 			$userIds = $result['users'];
 			if ($result['public']) {
 				$userIds[] = $this->publicShareKeyId;
@@ -1457,7 +1457,7 @@ class Util {
 
 		// Find out who, if anyone, is sharing the file
 		if ($sharingEnabled) {
-			$result = \OCP\Share::getUsersSharingFile($file, $this->userId, true, true, true);
+			$result = \OCP\Share::getUsersSharingFile($file, $this->userId, true);
 			$userIds = $result['users'];
 			$userIds[] = $this->recoveryKeyId;
 			if ($result['public']) {
diff --git a/lib/public/share.php b/lib/public/share.php
index 03d662676c62d8888f85c02a304b53c03baeb960..58e6131af58074d66f95c92a97d346446453c2f3 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -133,17 +133,16 @@ class Share {
 	* @note $path needs to be relative to user data dir, e.g. 'file.txt' 
 	*       not '/admin/data/file.txt'
 	*/
-	public static function getUsersSharingFile($path, $user, $includeOwner = false, $removeDuplicates = true) {
+	public static function getUsersSharingFile($path, $user, $includeOwner = false) {
 
-		$path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
-		$path = '';
 		$shares = array();
 		$publicShare = false;
 		$view = new \OC\Files\View('/' . $user . '/files/');
-		foreach ($path_parts as $p) {
-			$path .= '/' . $p;
-			$meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path));
-			$source = $meta['fileid'];
+		$meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path));
+		$source = $meta['fileid'];
+		$cache = new \OC\Files\Cache\Cache($meta['storage']);
+		
+		while ($path !== 'files') {
 
 			// Fetch all shares of this file path from DB
 			$query = \OC_DB::prepare(
@@ -203,6 +202,13 @@ class Share {
 			if ($result->fetchRow()) {
 				$publicShare = true;
 			}
+
+			// let's get the parent for the next round
+			$meta = $cache->get((int)$source);
+			$parent = $meta['parent'];
+			$parentMeta = $cache->get((int)$parent);
+			$path = $parentMeta['path'];
+			$source = $parent;
 		}
 		// Include owner in list of users, if requested
 		if ($includeOwner) {