diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index bbb315c4910a9cf7023981a81c643f999dca6449..4c485773e7b053fc4f040809f7801f89f2fab6e2 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -41,7 +41,7 @@ class Google extends \OC\Files\Storage\Common {
 		) {
 			$consumer_key = isset($params['consumer_key']) ? $params['consumer_key'] : 'anonymous';
 			$consumer_secret = isset($params['consumer_secret']) ? $params['consumer_secret'] : 'anonymous';
-			$this->id = 'google::' . $consumer_key . $consumer_secret;
+			$this->id = 'google::' . $params['token'];
 			$this->consumer = new \OAuthConsumer($consumer_key, $consumer_secret);
 			$this->oauth_token = new \OAuthToken($params['token'], $params['token_secret']);
 			$this->sig_method = new \OAuthSignatureMethod_HMAC_SHA1();
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 0534d6dd89fc4ad871b7fe830c9bc9299fcc0500..0b187a3c3ff10e852ff45bee698f38a8200e89eb 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -79,6 +79,8 @@ class Shared_Cache extends Cache {
 			$data['size'] = (int)$data['size'];
 			$data['mtime'] = (int)$data['mtime'];
 			$data['encrypted'] = (bool)$data['encrypted'];
+			$data['mimetype'] = $this->getMimetype($data['mimetype']);
+			$data['mimepart'] = $this->getMimetype($data['mimepart']);
 			return $data;
 		}
 		return false;
@@ -92,7 +94,12 @@ class Shared_Cache extends Cache {
 	 */
 	public function getFolderContents($folder) {
 		if ($folder == '') {
-			return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS);
+			$files = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS);
+			foreach ($files as &$file) {
+				$file['mimetype'] = $this->getMimetype($file['mimetype']);
+				$file['mimepart'] = $this->getMimetype($file['mimepart']);
+			}
+			return $files;
 		} else {
 			if ($cache = $this->getSourceCache($folder)) {
 				return $cache->getFolderContents($this->files[$folder]);
@@ -129,6 +136,19 @@ class Shared_Cache extends Cache {
 		return -1;
 	}
 
+	/**
+	 * check if a file is available in the cache
+	 *
+	 * @param string $file
+	 * @return bool
+	 */
+	public function inCache($file) {
+		if ($file == '') {
+			return true;
+		}
+		return parent::inCache($file);
+	}
+
 	/**
 	 * remove a file or folder from the cache
 	 *
@@ -176,7 +196,7 @@ class Shared_Cache extends Cache {
 		if ($cache = $this->getSourceCache($file)) {
 			return $cache->getStatus($this->files[$file]);
 		}
-		return false;
+		return self::NOT_FOUND;
 	}
 
 	/**
diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php
index 6eaed34b33d0c5d7803c9192ca867474cb7d2454..2b068ff93502f45ed68151b472ce9f7ca4826257 100644
--- a/apps/files_sharing/lib/permissions.php
+++ b/apps/files_sharing/lib/permissions.php
@@ -20,7 +20,7 @@
 */
 namespace OC\Files\Cache;
 
-class Shared_Permissions {
+class Shared_Permissions extends Permissions {
 
 	/**
 	 * get the permissions for a single file
@@ -29,11 +29,11 @@ class Shared_Permissions {
 	 * @param string $user
 	 * @return int (-1 if file no permissions set)
 	 */
-	static public function get($fileId, $user) {
+	public function get($fileId, $user) {
 		if ($fileId == -1) {
 			return \OCP\PERMISSION_READ;
 		}
-		$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
+		$source = \OCP\Share::getItemSharedWithBySource('file', $fileId, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE, null, true);
 		if ($source) {
 			return $source['permissions'];
 		} else {
@@ -48,7 +48,7 @@ class Shared_Permissions {
 	 * @param string $user
 	 * @param int $permissions
 	 */
-	static public function set($fileId, $user, $permissions) {
+	public function set($fileId, $user, $permissions) {
 		// Not a valid action for Shared Permissions
 	}
 
@@ -59,7 +59,7 @@ class Shared_Permissions {
 	 * @param string $user
 	 * @return int[]
 	 */
-	static public function getMultiple($fileIds, $user) {
+	public function getMultiple($fileIds, $user) {
 		if (count($fileIds) === 0) {
 			return array();
 		}
@@ -75,11 +75,11 @@ class Shared_Permissions {
 	 * @param int $fileId
 	 * @param string $user
 	 */
-	static public function remove($fileId, $user) {
+	public function remove($fileId, $user) {
 		// Not a valid action for Shared Permissions
 	}
 
-	static public function removeMultiple($fileIds, $user) {
+	public function removeMultiple($fileIds, $user) {
 		// Not a valid action for Shared Permissions
 	}
 }
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 5e98c455d35d5be22ae798915c92d68ed1ae4333..6d3c55a008f0bdaf85fc14674f6a3f55f7d01f51 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -117,6 +117,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
 	}
 
 	public static function getSource($target) {
+		if ($target == '') {
+			return false;
+		}
 		$target = '/'.$target;
 		$target = rtrim($target, '/');
 		$pos = strpos($target, '/', 1);
diff --git a/apps/files_sharing/lib/share/folder.php b/apps/files_sharing/lib/share/folder.php
index bbe4c130bddd79a3c484b0a204bbef119eb9a6d5..11c8c6b1e8066bd7d84dfbee563a5982607d3486 100644
--- a/apps/files_sharing/lib/share/folder.php
+++ b/apps/files_sharing/lib/share/folder.php
@@ -24,6 +24,13 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
 	public function getChildren($itemSource) {
 		$children = array();
 		$parents = array($itemSource);
+		$query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
+		$result = $query->execute(array('httpd/unix-directory'));
+		if ($row = $result->fetchRow()) {
+			$mimetype = $row['id'];
+		} else {
+			$mimetype = -1;
+		}
 		while (!empty($parents)) {
 			$parents = "'".implode("','", $parents)."'";
 			$query = OC_DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache` WHERE `parent` IN ('.$parents.')');
@@ -32,8 +39,8 @@ class OC_Share_Backend_Folder extends OC_Share_Backend_File implements OCP\Share
 			while ($file = $result->fetchRow()) {
 				$children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
 				// If a child folder is found look inside it
-				if ($file['mimetype'] == 'httpd/unix-directory') {
-					$parents[] = $file['id'];
+				if ($file['mimetype'] == $mimetype) {
+					$parents[] = $file['fileid'];
 				}
 			}
 		}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 24096e0c10c97c357089e0510b7734305f34b1aa..c8756af8ed72a9032e31b3b4f535f500069525e1 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -408,12 +408,6 @@ class Shared extends \OC\Files\Storage\Common {
 	}
 
 	public function getScanner($path = '') {
-		if ($path != '' && ($source = $this->getSourcePath($path))) {
-			list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
-			if ($storage) {
-				return $storage->getScanner($internalPath);
-			}
-		}
 		return new \OC\Files\Cache\Scanner($this);
 	}
 
diff --git a/db_structure.xml b/db_structure.xml
index 0116581be1281a13e1ea13c1be3d18e9937d7c44..f1f025728193e98dc3b3d0861f4c14a238272e9b 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -114,7 +114,7 @@
 				<type>text</type>
 				<default></default>
 				<notnull>true</notnull>
-				<length>64</length>
+				<length>255</length>
 			</field>
 
 			<index>
diff --git a/lib/files/view.php b/lib/files/view.php
index 7cc591497641146c99a430544c3df2c14614d8b7..06027910123985c455d0a33808f81c095ffab8e2 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -765,27 +765,37 @@ class View {
 				$subStorage = Filesystem::getStorage($mountPoint);
 				if ($subStorage) {
 					$subCache = $subStorage->getCache('');
-					$rootEntry = $subCache->get('');
 
-					$relativePath = trim(substr($mountPoint, $dirLength), '/');
-					if ($pos = strpos($relativePath, '/')) { //mountpoint inside subfolder add size to the correct folder
-						$entryName = substr($relativePath, 0, $pos);
-						foreach ($files as &$entry) {
-							if ($entry['name'] === $entryName) {
-								$entry['size'] += $rootEntry['size'];
+					if ($subCache->getStatus('') === Cache\Cache::NOT_FOUND) {
+						$subScanner = $subStorage->getScanner('');
+						$subScanner->scanFile('');
+					} else {
+						$subWatcher = $subStorage->getWatcher('');
+						$subWatcher->checkUpdate('');
+					}
+
+					$rootEntry = $subCache->get('');
+					if ($rootEntry) {
+						$relativePath = trim(substr($mountPoint, $dirLength), '/');
+						if ($pos = strpos($relativePath, '/')) { //mountpoint inside subfolder add size to the correct folder
+							$entryName = substr($relativePath, 0, $pos);
+							foreach ($files as &$entry) {
+								if ($entry['name'] === $entryName) {
+									$entry['size'] += $rootEntry['size'];
+								}
 							}
+						} else { //mountpoint in this folder, add an entry for it
+							$rootEntry['name'] = $relativePath;
+							$rootEntry['type'] = $rootEntry['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file';
+							$subPermissionsCache = $subStorage->getPermissionsCache('');
+							$permissions = $subPermissionsCache->get($rootEntry['fileid'], $user);
+							if ($permissions === -1) {
+								$permissions = $subStorage->getPermissions($rootEntry['path']);
+								$subPermissionsCache->set($rootEntry['fileid'], $user, $permissions);
+							}
+							$rootEntry['permissions'] = $permissions;
+							$files[] = $rootEntry;
 						}
-					} else { //mountpoint in this folder, add an entry for it
-						$rootEntry['name'] = $relativePath;
-						$rootEntry['type'] = $rootEntry['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file';
-						$subPermissionsCache = $subStorage->getPermissionsCache('');
-						$permissions = $subPermissionsCache->get($rootEntry['fileid'], $user);
-						if ($permissions === -1) {
-							$permissions = $subStorage->getPermissions($rootEntry['path']);
-							$subPermissionsCache->set($rootEntry['fileid'], $user, $permissions);
-						}
-						$rootEntry['permissions'] = $subPermissionsCache;
-						$files[] = $rootEntry;
 					}
 				}
 			}
diff --git a/lib/public/share.php b/lib/public/share.php
index c74960b94c536e21abaaa5e23fd6bd0488f0c26b..7722e0b86cc0d1703b6cf62da0a0f688fa9b1b19 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -756,7 +756,7 @@ class Share {
 			$collectionItems = array();
 			foreach ($items as &$row) {
 				// Return only the item instead of a 2-dimensional array
-				if ($limit == 1 && $row['item_type'] == $itemType && $row[$column] == $item) {
+				if ($limit == 1 && $row[$column] == $item && ($row['item_type'] == $itemType || $itemType == 'file')) {
 					if ($format == self::FORMAT_NONE) {
 						return $row;
 					} else {
@@ -823,6 +823,9 @@ class Share {
 			if (!empty($collectionItems)) {
 				$items = array_merge($items, $collectionItems);
 			}
+			if (empty($items) && $limit == 1) {
+				return false;
+			}
 			if ($format == self::FORMAT_NONE) {
 				return $items;
 			} else if ($format == self::FORMAT_STATUSES) {
diff --git a/lib/util.php b/lib/util.php
index 93c0d0f26d887304d4484317b3e095a2adb06a04..e814a3a32df45d03599dfc1edc69e9b677808b5a 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -74,7 +74,7 @@ class OC_Util {
 	 */
 	public static function getVersion() {
 		// hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user
-		return array(4,91,05);
+		return array(4,91,06);
 	}
 
 	/**