diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index c7347539fccfbf4023feee5a13bf8e7a1d36f23f..7a5b859826c293317a5d10343893185833c325e7 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -125,7 +125,7 @@ class Helper {
 
 
 		$ids = array();
-		while ($path !== '' && $path !== '.' && $path !== '/') {
+		while ($path !== dirname($path)) {
 			$info = $ownerView->getFileInfo($path);
 			if ($info instanceof \OC\Files\FileInfo) {
 				$ids[] = $info['fileid'];
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php
index 249211c306d86ce46005c8d4e0e64e326d7df702..43f5f144d100dd72ef6bfdbfeda7f1de63787211 100644
--- a/apps/files_sharing/lib/updater.php
+++ b/apps/files_sharing/lib/updater.php
@@ -38,7 +38,7 @@ class Shared_Updater {
 		\OC\Files\Filesystem::initMountPoints($user);
 		$view = new \OC\Files\View('/' . $user);
 		if ($view->file_exists($path)) {
-			while ($path !== '/') {
+			while ($path !== dirname($path)) {
 				$etag = $view->getETag($path);
 				$view->putFileInfo($path, array('etag' => $etag));
 				$path = dirname($path);