From b6dc6c5bb9903a85b634a0b4d57f5cf6657ea49b Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Fri, 21 Sep 2012 13:30:39 +0200
Subject: [PATCH] Don't use OC_FileCache directly, but use the functions in
 OC_Files

This adds getFileInfo to OC_Files to also get fileinfo from shared files
---
 lib/connector/sabre/directory.php |  8 +++++---
 lib/files.php                     | 28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index bbc615c0b1..3ea404455e 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -93,10 +93,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
 
 		$path = $this->path . '/' . $name;
 		if (is_null($info)) {
-			$info = OC_FileCache::get($path);
+			OC_Files::getFileInfo($path);
 		}
 
-		if (!$info) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+		if (!$info) {
+			throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+		}
 
 		if ($info['mimetype'] == 'httpd/unix-directory') {
 			$node = new OC_Connector_Sabre_Directory($path);
@@ -115,7 +117,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
 	 */
 	public function getChildren() {
 
-		$folder_content = OC_FileCache::getFolderContent($this->path);
+		$folder_content = OC_Files::getDirectoryContent($this->path);
 		$paths = array();
 		foreach($folder_content as $info) {
 			$paths[] = $this->path.'/'.$info['name'];
diff --git a/lib/files.php b/lib/files.php
index 63dd96b950..f7cc70959c 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -28,6 +28,34 @@
 class OC_Files {
 	static $tmpFiles=array();
 
+	/**
+	 * get the filesystem info
+	 * @param string path
+	 * @return array
+	 *
+	 * returns an associative array with the following keys:
+	 * - size
+	 * - mtime
+	 * - ctime
+	 * - mimetype
+	 * - encrypted
+	 * - versioned
+	 */
+	public static function getFileInfo($path) {
+		if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
+			if ($path == '/Shared') {
+				$info = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
+			}
+			else {
+				$info = OCP\Share::getItemSharedWith('file', '/'.$name, OC_Share_Backend_File::FORMAT_FILE_APP);
+			}
+			$info = $info[0];
+		}
+		else {
+			$info = OC_FileCache::get($path);
+		}
+	}
+
 	/**
 	* get the content of a directory
 	* @param dir $directory path under datadirectory
-- 
GitLab