[Pkg-owncloud-commits] [owncloud] 95/394: move the identification of the real path of a shared file to the filecache

David Prévot taffit at alioth.debian.org
Fri Nov 8 23:11:36 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.

commit cb0666e23595cddd40c3fc27abaa139fca71411b
Author: Björn Schießle <schiessle at owncloud.com>
Date:   Wed Nov 14 15:34:52 2012 +0100

    move the identification of the real path of a shared file to the filecache
---
 apps/files/ajax/upload.php |   15 ++-------------
 lib/filecache.php          |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 3a3d874..a4dcd80 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -49,19 +49,8 @@ if(strpos($dir, '..') === false) {
 	for($i=0;$i<$fileCount;$i++) {
         $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
 		if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
-			if ( OC_App::isEnabled('files_sharing') &&  !strncmp($target, '/Shared/', 8)) {
-				$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $target));
-				$parts = explode('/', $source, 4);
-				$root =  '/'.$parts[1].'/files';
-				$path = '/'.$parts[3];
-			} else {
-				$path = $target;
-				$root = false;
-			}
-				
-			$meta = OC_FileCache::get($path, $root);
-			$id = OC_FileCache::getId($path, $root);
-
+			$meta = OC_FileCache::get($target);
+			$id = OC_FileCache::getId($target);
 			$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
 		}
 	}
diff --git a/lib/filecache.php b/lib/filecache.php
index 40d6302..5fa32fb 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -43,6 +43,9 @@ class OC_FileCache{
 	 * - versioned
 	 */
 	public static function get($path,$root=false) {
+		
+		list($path, $root) = self::getSourcePathOfSharedFile($path);
+		
 		if(OC_FileCache_Update::hasUpdated($path,$root)) {
 			if($root===false) {//filesystem hooks are only valid for the default root
 				OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path));
@@ -277,6 +280,9 @@ class OC_FileCache{
 	 * @return int
 	 */
 	public static function getId($path,$root=false) {
+		
+		list($path, $root) = self::getSourcePathOfSharedFile($path);
+			
 		if($root===false) {
 			$root=OC_Filesystem::getRoot();
 		}
@@ -507,6 +513,24 @@ class OC_FileCache{
 			$query->execute(array('httpd/unix-directory'));
 		}
 	}
+	
+	/**
+	 * get the real path and the root of a shared file
+	 * @param string $path
+	 * @return array with the path and the root of the give file
+	 */
+	private static function getSourcePathOfSharedFile($path) {
+		if ( OC_App::isEnabled('files_sharing') &&  !strncmp($path, '/Shared/', 8)) {
+			$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path));
+			$parts = explode('/', $source, 4);
+			$root =  '/'.$parts[1].'/files';
+			$path = '/'.$parts[3];
+		} else {
+			$root = false; 
+		}
+		
+		return array($path, $root);
+	}
 }
 
 //watch for changes and try to keep the cache up to date

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list