|
|
|
@ -59,8 +59,8 @@ class OC_FileCache{ |
|
|
|
$root=''; |
|
|
|
} |
|
|
|
$path=$root.$path; |
|
|
|
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path=?'); |
|
|
|
$result=$query->execute(array($path))->fetchRow(); |
|
|
|
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path_hash=?'); |
|
|
|
$result=$query->execute(array(md5($path)))->fetchRow(); |
|
|
|
if(is_array($result)){ |
|
|
|
return $result; |
|
|
|
}else{ |
|
|
|
@ -111,8 +111,8 @@ class OC_FileCache{ |
|
|
|
} |
|
|
|
$mimePart=dirname($data['mimetype']); |
|
|
|
$user=OC_User::getUser(); |
|
|
|
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user,writable,encrypted,versioned) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)'); |
|
|
|
$result=$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned'])); |
|
|
|
$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'])); |
|
|
|
if(OC_DB::isError($result)){ |
|
|
|
OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR); |
|
|
|
} |
|
|
|
@ -162,8 +162,8 @@ class OC_FileCache{ |
|
|
|
$oldPath=$root.$oldPath; |
|
|
|
$newPath=$root.$newPath; |
|
|
|
$newParent=self::getParentId($newPath); |
|
|
|
$query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=? WHERE path=?'); |
|
|
|
$query->execute(array($newParent,basename($newPath),$newPath,$oldPath)); |
|
|
|
$query=OC_DB::prepare('UPDATE *PREFIX*fscache SET parent=? ,name=?, path=?, path_hash=? WHERE path_hash=?'); |
|
|
|
$query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath))); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -285,12 +285,12 @@ class OC_FileCache{ |
|
|
|
* @return int |
|
|
|
*/ |
|
|
|
private static function getFileId($path){ |
|
|
|
$query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?'); |
|
|
|
$query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path_hash=?'); |
|
|
|
if(OC_DB::isError($query)){ |
|
|
|
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
$result=$query->execute(array($path)); |
|
|
|
$result=$query->execute(array(md5($path))); |
|
|
|
if(OC_DB::isError($result)){ |
|
|
|
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); |
|
|
|
return -1; |
|
|
|
@ -367,8 +367,8 @@ class OC_FileCache{ |
|
|
|
} |
|
|
|
} |
|
|
|
$path=$root.$path; |
|
|
|
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path=?'); |
|
|
|
$result=$query->execute(array($path))->fetchRow(); |
|
|
|
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path_hash=?'); |
|
|
|
$result=$query->execute(array(md5($path)))->fetchRow(); |
|
|
|
if(is_array($result)){ |
|
|
|
if(isset(self::$savedData[$path])){ |
|
|
|
$result=array_merge($result,self::$savedData[$path]); |
|
|
|
@ -389,8 +389,8 @@ class OC_FileCache{ |
|
|
|
} |
|
|
|
} |
|
|
|
$path=$root.$path; |
|
|
|
$query=OC_DB::prepare('SELECT size FROM *PREFIX*fscache WHERE path=?'); |
|
|
|
$result=$query->execute(array($path)); |
|
|
|
$query=OC_DB::prepare('SELECT size FROM *PREFIX*fscache WHERE path_hash=?'); |
|
|
|
$result=$query->execute(array(md5($path))); |
|
|
|
if($row=$result->fetchRow()){ |
|
|
|
return $row['size']; |
|
|
|
}else{//file not in cache
|
|
|
|
@ -579,8 +579,8 @@ class OC_FileCache{ |
|
|
|
$mtime=$view->filemtime($path); |
|
|
|
$isDir=$view->is_dir($path); |
|
|
|
$path=$root.$path; |
|
|
|
$query=OC_DB::prepare('SELECT mtime FROM *PREFIX*fscache WHERE path=?'); |
|
|
|
$result=$query->execute(array($path)); |
|
|
|
$query=OC_DB::prepare('SELECT mtime FROM *PREFIX*fscache WHERE path_hash=?'); |
|
|
|
$result=$query->execute(array(md5($path))); |
|
|
|
if($row=$result->fetchRow()){ |
|
|
|
$cachedMTime=$row['mtime']; |
|
|
|
return ($mtime>$cachedMTime); |
|
|
|
|