From 8bdfb040565eafb33bc27305463eb08374f14e32 Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <mtgap@owncloud.com>
Date: Fri, 28 Dec 2012 15:06:12 -0500
Subject: [PATCH] Fix shared folders

---
 apps/files_sharing/lib/cache.php | 17 ++++++++++++++---
 lib/files/filesystem.php         |  1 +
 lib/util.php                     |  1 -
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 196e767cf6..d2ac8ccaaa 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -30,6 +30,10 @@ class Shared_Cache extends Cache {
 
 	private $files = array();
 
+	public function __construct($storage) {
+		
+	}
+
 	/**
 	* @brief Get the source cache of a shared file or folder
 	* @param string Shared target file path
@@ -41,8 +45,12 @@ class Shared_Cache extends Cache {
 			$source['path'] = '/'.$source['uid_owner'].'/'.$source['path'];
 			\OC\Files\Filesystem::initMountPoints($source['uid_owner']);
 			list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source['path']);
-			$this->files[$target] = $internalPath;
-			return $storage->getCache();
+			if ($storage) {
+				$this->files[$target] = $internalPath;
+				$cache = $storage->getCache();
+				$this->numericId = $cache->getNumericStorageId();
+				return $cache;
+			}
 		}
 		return false;
 	}
@@ -83,8 +91,11 @@ class Shared_Cache extends Cache {
 		if ($folder == '') {
 			return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS);
 		} else {
-			return $this->getSourceCache($folder)->getFolderContents('/'.$this->files[$folder]);
+			if ($cache = $this->getSourceCache($folder)) {
+				return $cache->getFolderContents($this->files[$folder]);
+			}
 		}
+		return false;
 	}
 
 	/**
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index c5b56ba9f0..8183b8ff99 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -276,6 +276,7 @@ class Filesystem {
 		}
 		// Load personal mount points
 		$root = \OC_User::getHome($user);
+		self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
 		if (is_file($root.'/mount.php')) {
 			$mountConfig = include $root.'/mount.php';
 			if (isset($mountConfig['user'][$user])) {
diff --git a/lib/util.php b/lib/util.php
index 4ebc2564d1..c5a495234d 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -51,7 +51,6 @@ class OC_Util {
 				mkdir( $userdirectory, 0755, true );
 			}
 			//jail the user into his "home" directory
-			\OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir' => $user_root), $user);
 			\OC\Files\Filesystem::init($user_dir);
 
 			$quotaProxy=new OC_FileProxy_Quota();
-- 
GitLab