store writable flag for files

This commit is contained in:
Robin Appelman 2012-02-05 14:04:10 +01:00
parent 30673e4786
commit 9f3388ecbc
2 changed files with 19 additions and 8 deletions

View File

@ -151,8 +151,16 @@
<length>1</length> <length>1</length>
</field> </field>
<!-- <index> <field>
<name>fscache_path_index</name> <name>writable</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>1</length>
</field>
<!--<index>
<name>fscache_path_index</name>
<unique>true</unique> <unique>true</unique>
<field> <field>
<name>path</name> <name>path</name>

View File

@ -57,7 +57,7 @@ class OC_FileCache{
$root=''; $root='';
} }
$path=$root.$path; $path=$root.$path;
$query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned FROM *PREFIX*fscache WHERE path=?'); $query=OC_DB::prepare('SELECT ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE path=?');
$result=$query->execute(array($path))->fetchRow(); $result=$query->execute(array($path))->fetchRow();
if(is_array($result)){ if(is_array($result)){
return $result; return $result;
@ -101,8 +101,8 @@ class OC_FileCache{
} }
$mimePart=dirname($data['mimetype']); $mimePart=dirname($data['mimetype']);
$user=OC_User::getUser(); $user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user) VALUES(?,?,?,?,?,?,?,?,?)'); $query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user,writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user)); $query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable']));
} }
@ -114,7 +114,7 @@ class OC_FileCache{
private static function update($id,$data){ private static function update($id,$data){
$arguments=array(); $arguments=array();
$queryParts=array(); $queryParts=array();
foreach(array('size','mtime','ctime','mimetype','encrypted','versioned') as $attribute){ foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){
if(isset($data[$attribute])){ if(isset($data[$attribute])){
$arguments[]=$data[$attribute]; $arguments[]=$data[$attribute];
$queryParts[]=$attribute.'=?'; $queryParts[]=$attribute.'=?';
@ -226,7 +226,7 @@ class OC_FileCache{
} }
$path=$root.$path; $path=$root.$path;
$parent=self::getFileId($path); $parent=self::getFileId($path);
$query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned FROM *PREFIX*fscache WHERE parent=?'); $query=OC_DB::prepare('SELECT name,ctime,mtime,mimetype,size,encrypted,versioned,writable FROM *PREFIX*fscache WHERE parent=?');
$result=$query->execute(array($parent))->fetchAll(); $result=$query->execute(array($parent))->fetchAll();
if(is_array($result)){ if(is_array($result)){
return $result; return $result;
@ -309,7 +309,8 @@ class OC_FileCache{
} }
$mtime=$view->filemtime($path); $mtime=$view->filemtime($path);
$ctime=$view->filectime($path); $ctime=$view->filectime($path);
self::put($path,array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype)); $writable=$view->is_writable($path);
self::put($path,array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype,'writable'=>$writable));
}else{ }else{
self::scan($path,null,0,$root); self::scan($path,null,0,$root);
} }
@ -450,7 +451,9 @@ class OC_FileCache{
if(!$view->is_readable($path)) return; //cant read, nothing we can do if(!$view->is_readable($path)) return; //cant read, nothing we can do
$stat=$view->stat($path); $stat=$view->stat($path);
$mimetype=$view->getMimeType($path); $mimetype=$view->getMimeType($path);
$writable=$view->is_writable($path);
$stat['mimetype']=$mimetype; $stat['mimetype']=$mimetype;
$stat['writable']=$writable;
if($path=='/'){ if($path=='/'){
$path=''; $path='';
} }