diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 47cbf35836c6e204a3c60087909db232ad00170d..73daf8a141f1db4f0b4419e1b02ab7346c05ea97 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1081,7 +1081,8 @@ class View {
 		if ($this->fakeRoot === $defaultRoot) {
 			return true;
 		}
-		return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
+		$fullPath = $this->getAbsolutePath($path);
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
 	}
 
 	/**
@@ -1091,10 +1092,11 @@ class View {
 	 * @return bool
 	 */
 	private function runHooks($hooks, $path, $post = false) {
+		$relativePath = $path;
 		$path = $this->getHookPath($path);
 		$prefix = ($post) ? 'post_' : '';
 		$run = true;
-		if ($this->shouldEmitHooks($path)) {
+		if ($this->shouldEmitHooks($relativePath)) {
 			foreach ($hooks as $hook) {
 				if ($hook != 'read') {
 					\OC_Hook::emit(
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index dcdebfd9bceb2e8580875735fa7a48483e2d4b26..9862026495f11593adbc6939e59ba9539d21e75b 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -1230,4 +1230,33 @@ class View extends \Test\TestCase {
 		$this->assertFalse($this->isFileLocked($view, '/test//sub', ILockingProvider::LOCK_EXCLUSIVE));
 
 	}
+
+	public function hookPathProvider() {
+		return [
+			['/foo/files', '/foo', true],
+			['/foo/files/bar', '/foo', true],
+			['/foo', '/foo', false],
+			['/foo', '/files/foo', true],
+			['/foo', 'filesfoo', false]
+		];
+	}
+
+	/**
+	 * @dataProvider hookPathProvider
+	 * @param $root
+	 * @param $path
+	 * @param $shouldEmit
+	 */
+	public function testHookPaths($root, $path, $shouldEmit) {
+		$filesystemReflection = new \ReflectionClass('\OC\Files\Filesystem');
+		$defaultRootValue = $filesystemReflection->getProperty('defaultInstance');
+		$defaultRootValue->setAccessible(true);
+		$oldRoot = $defaultRootValue->getValue();
+		$defaultView = new \OC\Files\View('/foo/files');
+		$defaultRootValue->setValue($defaultView);
+		$view = new \OC\Files\View($root);
+		$result = \Test_Helper::invokePrivate($view, 'shouldEmitHooks', [$path]);
+		$defaultRootValue->setValue($oldRoot);
+		$this->assertEquals($shouldEmit, $result);
+	}
 }