diff options
27 files changed, 177 insertions, 67 deletions
diff --git a/apps/files_archive/appinfo/info.xml b/apps/files_archive/appinfo/info.xml index df767d39f6b..236b5a64b05 100644 --- a/apps/files_archive/appinfo/info.xml +++ b/apps/files_archive/appinfo/info.xml @@ -7,4 +7,7 @@ <licence>AGPL</licence> <author>Robin Appelman</author> <require>3</require> + <types> + <filesystem/> + </types> </info> diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index 053044aaed2..691b265bf60 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -7,4 +7,7 @@ <licence>AGPL</licence> <author>Robin Appelman</author> <require>3</require> + <types> + <filesystem/> + </types> </info> diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php new file mode 100644 index 00000000000..95770b44b75 --- /dev/null +++ b/apps/files_external/appinfo/app.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php'; +OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php'; +OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php'; diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml new file mode 100644 index 00000000000..fb58297ff17 --- /dev/null +++ b/apps/files_external/appinfo/info.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<info> + <id>files_external</id> + <name>External storage support</name> + <description>Mount external storage sources</description> + <version>0.1</version> + <licence>AGPL</licence> + <author>Robin Appelman</author> + <require>3</require> + <types> + <filesystem/> + </types> +</info> diff --git a/apps/files_remote/lib/ftp.php b/apps/files_external/lib/ftp.php index 802446b4fd8..802446b4fd8 100644 --- a/apps/files_remote/lib/ftp.php +++ b/apps/files_external/lib/ftp.php diff --git a/apps/files_remote/lib/google.php b/apps/files_external/lib/google.php index 0d6db1987f8..0d6db1987f8 100644 --- a/apps/files_remote/lib/google.php +++ b/apps/files_external/lib/google.php diff --git a/apps/files_remote/lib/webdav.php b/apps/files_external/lib/webdav.php index 7a2da5c8ec0..7a2da5c8ec0 100644 --- a/apps/files_remote/lib/webdav.php +++ b/apps/files_external/lib/webdav.php diff --git a/apps/files_remote/tests/config.php b/apps/files_external/tests/config.php index 9b40d2b98cf..9b40d2b98cf 100644 --- a/apps/files_remote/tests/config.php +++ b/apps/files_external/tests/config.php diff --git a/apps/files_remote/tests/ftp.php b/apps/files_external/tests/ftp.php index 03633b7c0d1..aa565751ba3 100644 --- a/apps/files_remote/tests/ftp.php +++ b/apps/files_external/tests/ftp.php @@ -12,7 +12,7 @@ class Test_Filestorage_FTP extends Test_FileStorage { public function setUp(){ $id=uniqid(); - $this->config=include('apps/files_remote/tests/config.php'); + $this->config=include('apps/files_external/tests/config.php'); $this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_FTP($this->config['ftp']); } diff --git a/apps/files_remote/tests/google.php b/apps/files_external/tests/google.php index b49f9e4647c..1c028945228 100644 --- a/apps/files_remote/tests/google.php +++ b/apps/files_external/tests/google.php @@ -27,7 +27,7 @@ class Test_Filestorage_Google extends Test_FileStorage { public function setUp(){ $id=uniqid(); - $this->config=include('apps/files_remote/tests/config.php'); + $this->config=include('apps/files_external/tests/config.php'); $this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_Google($this->config['google']); } @@ -35,4 +35,4 @@ class Test_Filestorage_Google extends Test_FileStorage { public function tearDown(){ $this->instance->rmdir('/'); } -}
\ No newline at end of file +} diff --git a/apps/files_remote/tests/webdav.php b/apps/files_external/tests/webdav.php index 219fff8852d..51799290540 100644 --- a/apps/files_remote/tests/webdav.php +++ b/apps/files_external/tests/webdav.php @@ -12,7 +12,7 @@ class Test_Filestorage_DAV extends Test_FileStorage { public function setUp(){ $id=uniqid(); - $this->config=include('apps/files_remote/tests/config.php'); + $this->config=include('apps/files_external/tests/config.php'); $this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_DAV($this->config['webdav']); } diff --git a/apps/files_remote/appinfo/app.php b/apps/files_remote/appinfo/app.php deleted file mode 100644 index 02c1c3ae313..00000000000 --- a/apps/files_remote/appinfo/app.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -/** - * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_remote/lib/ftp.php'; -OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_remote/lib/webdav.php'; -OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_remote/lib/google.php'; diff --git a/apps/files_remote/appinfo/info.xml b/apps/files_remote/appinfo/info.xml deleted file mode 100644 index 0720b6095b9..00000000000 --- a/apps/files_remote/appinfo/info.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<info> - <id>files_remote</id> - <name>Remote storage support</name> - <description>Mount remote storage sources</description> - <version>0.1</version> - <licence>AGPL</licence> - <author>Robin Appelman</author> - <require>3</require> -</info> diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index abf847b4483..8fda775520b 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -8,4 +8,7 @@ <author>Michael Gapczynski</author> <require>2</require> <default_enable/> + <types> + <filesystem/> + </types> </info> diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 3e7e38301cf..f7e0651275e 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -32,14 +32,14 @@ $l = new OC_L10N('gallery'); OC_App::register(array( 'order' => 20, 'id' => 'gallery', - 'name' => 'Gallery')); + 'name' => 'Pictures')); OC_App::addNavigationEntry( array( 'id' => 'gallery_index', 'order' => 20, 'href' => OC_Helper::linkTo('gallery', 'index.php'), 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'), - 'name' => $l->t('Gallery'))); + 'name' => $l->t('Pictures'))); class OC_GallerySearchProvider implements OC_Search_Provider{ static function search($query){ diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml index 19c5dc8b25e..4c8c1cee242 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -1,11 +1,11 @@ <?xml version="1.0"?> <info> <id>gallery</id> - <name>Gallery</name> + <name>Pictures</name> <version>0.4</version> <licence>AGPL</licence> <author>Bartek Przybylski</author> <require>2</require> - <description>Gallery application for ownCloud</description> + <description>Dedicated pictures application</description> <default_enable/> </info> diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml index 121587795db..0936bf9bd0f 100644 --- a/apps/remoteStorage/appinfo/info.xml +++ b/apps/remoteStorage/appinfo/info.xml @@ -2,7 +2,7 @@ <info> <id>remoteStorage</id> <name>remoteStorage compatibility</name> - <description>Enables your users to use ownCloud as their remote storage for unhosted applications.</description> + <description>Enables you to use ownCloud as their remote storage for unhosted applications. This app requires the Webfinger app to be enabled as well. More info on <a href="http://unhosted.org">the website of the unhosted movement</a>.</description> <version>0.5</version> <licence>AGPL or MIT</licence> <author>Michiel de Jong</author> diff --git a/db_structure.xml b/db_structure.xml index 5eef44d8e84..82d2a731d4c 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -65,6 +65,15 @@ </field> <field> + <name>path_hash</name> + <type>text</type> + <default> + </default> + <notnull>true</notnull> + <length>32</length> + </field> + + <field> <name>parent</name> <type>integer</type> <default> @@ -79,7 +88,7 @@ <default> </default> <notnull>true</notnull> - <length>512</length> + <length>300</length> </field> <field> @@ -159,14 +168,13 @@ <length>1</length> </field> - <!--<index> - <name>fscache_path_index</name> - <unique>true</unique> + <index> + <name>fscache_path_hash_index</name> <field> - <name>path</name> + <name>path_hash</name> <sorting>ascending</sorting> </field> - </index>--> + </index> <index> <name>parent_index</name> @@ -177,6 +185,14 @@ </index> <index> + <name>name_index</name> + <field> + <name>name</name> + <sorting>ascending</sorting> + </field> + </index> + + <index> <name>parent_name_index</name> <field> <name>parent</name> diff --git a/files/ajax/download.php b/files/ajax/download.php index 198069f3fa1..39852613ab9 100644 --- a/files/ajax/download.php +++ b/files/ajax/download.php @@ -21,6 +21,9 @@ * */ +// only need filesystem apps +$RUNTIME_APPTYPES=array('filesystem'); + // Init owncloud require_once('../../lib/base.php'); diff --git a/files/ajax/list.php b/files/ajax/list.php index 8a414827e1c..ec9ab7342dd 100644 --- a/files/ajax/list.php +++ b/files/ajax/list.php @@ -1,5 +1,8 @@ <?php +// only need filesystem apps +$RUNTIME_APPTYPES=array('filesystem'); + // Init owncloud require_once('../../lib/base.php'); diff --git a/files/ajax/mimeicon.php b/files/ajax/mimeicon.php index 8724016b3a1..ff72ba0f5b7 100644 --- a/files/ajax/mimeicon.php +++ b/files/ajax/mimeicon.php @@ -1,5 +1,8 @@ <?php +// no need for apps +$RUNTIME_NOAPPS=false; + // Init owncloud require_once('../../lib/base.php'); diff --git a/files/webdav.php b/files/webdav.php index 6fae33a8f71..1120973787c 100644 --- a/files/webdav.php +++ b/files/webdav.php @@ -26,6 +26,9 @@ // Do not load FS ... $RUNTIME_NOSETUPFS = true; +// only need filesystem apps +$RUNTIME_APPTYPES=array('filesystem'); + require_once('../lib/base.php'); // Backends diff --git a/lib/app.php b/lib/app.php index 3daf539aa21..6c882963a02 100755 --- a/lib/app.php +++ b/lib/app.php @@ -34,16 +34,20 @@ class OC_App{ static private $settingsForms = array(); static private $adminForms = array(); static private $personalForms = array(); + static private $appInfo = array(); /** * @brief loads all apps + * @param array $types * @returns true/false * * This function walks through the owncloud directory and loads all apps * it can find. A directory contains an app if the file /appinfo/app.php * exists. + * + * if $types is set, only apps of those types will be loaded */ - public static function loadApps(){ + public static function loadApps($types=null){ // Did we allready load everything? if( self::$init ){ return true; @@ -51,13 +55,15 @@ class OC_App{ // Our very own core apps are hardcoded foreach( array('files', 'settings') as $app ){ - require( $app.'/appinfo/app.php' ); + if(is_null($types) or self::isType($app,$types)){ + require( $app.'/appinfo/app.php' ); + } } // The rest comes here - $apps = OC_Appconfig::getApps(); + $apps = self::getEnabledApps(); foreach( $apps as $app ){ - if( self::isEnabled( $app )){ + if(is_null($types) or self::isType($app,$types)){ if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){ require( $app.'/appinfo/app.php' ); } @@ -71,6 +77,41 @@ class OC_App{ } /** + * check if an app is of a sepcific type + * @param string $app + * @param string/array $types + */ + public static function isType($app,$types){ + if(is_string($types)){ + $types=array($types); + } + $appData=self::getAppInfo($app); + if(!isset($appData['types'])){ + return false; + } + $appTypes=$appData['types']; + foreach($types as $type){ + if(array_search($type,$appTypes)!==false){ + return true; + } + } + return false; + } + + /** + * get all enabled apps + */ + public static function getEnabledApps(){ + $apps=array(); + $query = OC_DB::prepare( 'SELECT appid FROM *PREFIX*appconfig WHERE configkey = "enabled" AND configvalue="yes"' ); + $query->execute(); + while($row=$query->fetchRow()){ + $apps[]=$row['appid']; + } + return $apps; + } + + /** * @brief checks whether or not an app is enabled * @param $app app * @returns true/false @@ -265,24 +306,36 @@ class OC_App{ /** * @brief Read app metadata from the info.xml file * @param string $appid id of the app or the path of the info.xml file + * @param boolean path (optional) * @returns array */ - public static function getAppInfo($appid){ - if(is_file($appid)){ + public static function getAppInfo($appid,$path=false){ + if($path){ $file=$appid; }else{ - $file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml'; - if(!is_file($file)){ - return array(); + if(isset(self::$appInfo[$appid])){ + return self::$appInfo[$appid]; } + $file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/info.xml'; } $data=array(); $content=file_get_contents($file); + if(!$content){ + return; + } $xml = new SimpleXMLElement($content); $data['info']=array(); foreach($xml->children() as $child){ - $data[$child->getName()]=(string)$child; + if($child->getName()=='types'){ + $data['types']=array(); + foreach($child->children() as $type){ + $data['types'][]=$type->getName(); + } + }else{ + $data[$child->getName()]=(string)$child; + } } + self::$appInfo[$appid]=$data; return $data; } @@ -381,9 +434,8 @@ class OC_App{ */ public static function updateApps(){ // The rest comes here - $apps = OC_Appconfig::getApps(); - foreach( $apps as $app ){ - $installedVersion=OC_Appconfig::getValue($app,'installed_version'); + $versions = self::getAppVersions(); + foreach( $versions as $app=>$installedVersion ){ $appInfo=OC_App::getAppInfo($app); if (isset($appInfo['version'])) { $currentVersion=$appInfo['version']; @@ -396,6 +448,19 @@ class OC_App{ } /** + * get the installed version of all papps + */ + public static function getAppVersions(){ + $versions=array(); + $query = OC_DB::prepare( 'SELECT appid, configvalue FROM *PREFIX*appconfig WHERE configkey = "installed_version"' ); + $result = $query->execute(); + while($row = $result->fetchRow()){ + $versions[$row['appid']]=$row['configvalue']; + } + return $versions; + } + + /** * update the database for the app and call the update script * @param string appid */ diff --git a/lib/base.php b/lib/base.php index b07ac5af416..b031572f177 100644 --- a/lib/base.php +++ b/lib/base.php @@ -333,8 +333,13 @@ class OC{ // Load Apps // This includes plugins for users and filesystems as well global $RUNTIME_NOAPPS; + global $RUNTIME_APPTYPES; if(!$RUNTIME_NOAPPS ){ - OC_App::loadApps(); + if($RUNTIME_APPTYPES){ + OC_App::loadApps($RUNTIME_APPTYPES); + }else{ + OC_App::loadApps(); + } } //make sure temporary files are cleaned up diff --git a/lib/filecache.php b/lib/filecache.php index 280a9929db0..a8c48e3f144 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -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); diff --git a/lib/installer.php b/lib/installer.php index c5ecacae544..38e17130e3c 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -123,7 +123,7 @@ class OC_Installer{ } return false; } - $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml'); + $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true); $basedir=OC::$APPSROOT.'/apps/'.$info['id']; //check if an app with the same id is already installed @@ -296,7 +296,7 @@ class OC_Installer{ if(is_file(OC::$APPSROOT."/apps/$app/appinfo/install.php")){ include(OC::$APPSROOT."/apps/$app/appinfo/install.php"); } - $info=OC_App::getAppInfo(OC::$APPSROOT."/apps/$app/appinfo/info.xml"); + $info=OC_App::getAppInfo($app); OC_Appconfig::setValue($app,'installed_version',$info['version']); return $info; } diff --git a/lib/util.php b/lib/util.php index fa5b3daaab6..529b6d958fb 100644 --- a/lib/util.php +++ b/lib/util.php @@ -66,7 +66,7 @@ class OC_Util { * @return array */ public static function getVersion(){ - return array(3,00,3); + return array(3,00,4); } /** |