]> source.dussan.org Git - nextcloud-server.git/commitdiff
store writable flag for files
authorRobin Appelman <icewind@owncloud.com>
Sun, 5 Feb 2012 13:04:10 +0000 (14:04 +0100)
committerRobin Appelman <icewind@owncloud.com>
Sun, 5 Feb 2012 13:04:10 +0000 (14:04 +0100)
db_structure.xml
lib/filecache.php

index 5ef22b595cfa3439a49f34bae19050c24780bfcd..8e59a59c6e51e354c16d56499fdc9219a4820458 100644 (file)
           <length>1</length>
    </field>
 
-<!--   <index>
-    <name>fscache_path_index</name>
+   <field>
+          <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>
     <field>
      <name>path</name>
index c51fee60bfe3413ab5d422f2740103fce36b3aad..e3f7fedeecf337f7447218de53414f48af320b93 100644 (file)
@@ -57,7 +57,7 @@ class OC_FileCache{
                        $root='';
                }
                $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();
                if(is_array($result)){
                        return $result;
@@ -101,8 +101,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) VALUES(?,?,?,?,?,?,?,?,?)');
-               $query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user));
+               $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,$data['writable']));
                
        }
 
@@ -114,7 +114,7 @@ class OC_FileCache{
        private static function update($id,$data){
                $arguments=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])){
                                $arguments[]=$data[$attribute];
                                $queryParts[]=$attribute.'=?';
@@ -226,7 +226,7 @@ class OC_FileCache{
                }
                $path=$root.$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();
                if(is_array($result)){
                        return $result;
@@ -309,7 +309,8 @@ class OC_FileCache{
                                }
                                $mtime=$view->filemtime($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{
                                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
                $stat=$view->stat($path);
                $mimetype=$view->getMimeType($path);
+               $writable=$view->is_writable($path);
                $stat['mimetype']=$mimetype;
+               $stat['writable']=$writable;
                if($path=='/'){
                        $path='';
                }