[Pkg-owncloud-commits] [owncloud] 07/73: fix for bug 879 - add parent directory to file cache if it does not exist yet. For example this can happen if the sync client is used before the user created the root directory (e.g. through web login).

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


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

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

commit 2cfc7f7454fb29e1aba1420a8d3df5cdcb8ff852
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Wed Aug 8 11:47:23 2012 +0200

    fix for bug 879 - add parent directory to file cache if it does not exist yet.
    For example this can happen if the sync client is used before the user created the root directory (e.g. through web login).
---
 lib/filecache.php |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/lib/filecache.php b/lib/filecache.php
index 8d0f3c8..7b7a2fa 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -84,19 +84,28 @@ class OC_FileCache{
 		if($root=='/'){
 			$root='';
 		}
-		$path=$root.$path;
-		$parent=self::getParentId($path);
-		$id=self::getFileId($path);
-		if(isset(OC_FileCache::$savedData[$path])){
-			$data=array_merge(OC_FileCache::$savedData[$path],$data);
-			unset(OC_FileCache::$savedData[$path]);
+		$fullpath=$root.$path;
+		$parent=self::getParentId($fullpath);
+		$id=self::getFileId($fullpath);
+		if(isset(OC_FileCache::$savedData[$fullpath])){
+			$data=array_merge(OC_FileCache::$savedData[$fullpath],$data);
+			unset(OC_FileCache::$savedData[$fullpath]);
+		}
+		
+		// add parent directory to the file cache if it does not exist yet.
+		if ($parent == -1 && $fullpath != $root) {
+			$parentDir = substr(dirname($path), 0, strrpos(dirname($path), DIRECTORY_SEPARATOR));
+			self::scanFile($parentDir);
+			$parent = self::getParentId($fullpath);
 		}
+		
 		if($id!=-1){
 			self::update($id,$data);
 			return;
 		}
+		
 		if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it
-			self::$savedData[$path]=$data;
+			self::$savedData[$fullpath]=$data;
 			return;
 		}
 		if(!isset($data['encrypted'])){
@@ -113,9 +122,9 @@ class OC_FileCache{
 		$data['versioned']=(int)$data['versioned'];
 		$user=OC_User::getUser();
 		$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, path_hash, size, mtime, ctime, mimetype, mimepart,`user`,writable,encrypted,versioned) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
-		$result=$query->execute(array($parent,basename($path),$path,md5($path),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
+		$result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
 		if(OC_DB::isError($result)){
-			OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR);
+			OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR);
 		}
 	}
 

-- 
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