From 7bc9fa765c75846e5a293ea534505d3722d612f5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 30 Mar 2012 13:48:44 +0200 Subject: [PATCH 1/7] optimizations for updateApps --- lib/app.php | 29 +++++++++++++++++++++-------- lib/installer.php | 4 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/app.php b/lib/app.php index 3daf539aa2..5ee9a0e565 100755 --- a/lib/app.php +++ b/lib/app.php @@ -265,19 +265,20 @@ 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(); - } } $data=array(); $content=file_get_contents($file); + if(!$content){ + return; + } $xml = new SimpleXMLElement($content); $data['info']=array(); foreach($xml->children() as $child){ @@ -381,9 +382,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']; @@ -395,6 +395,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/installer.php b/lib/installer.php index c5ecacae54..38e17130e3 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; } From a07c6b1a2ea66f00b3e85d480703ca06a4b241be Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 30 Mar 2012 14:00:24 +0200 Subject: [PATCH 2/7] optimizations for loadApps --- lib/app.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/app.php b/lib/app.php index 5ee9a0e565..fa0a1d22d1 100755 --- a/lib/app.php +++ b/lib/app.php @@ -55,12 +55,10 @@ class OC_App{ } // The rest comes here - $apps = OC_Appconfig::getApps(); + $apps = self::getEnabledApps(); foreach( $apps as $app ){ - if( self::isEnabled( $app )){ - if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){ - require( $app.'/appinfo/app.php' ); - } + if(is_file(OC::$APPSROOT.'/apps/'.$app.'/appinfo/app.php')){ + require( $app.'/appinfo/app.php' ); } } @@ -70,6 +68,19 @@ class OC_App{ return true; } + /** + * 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 From 523fdda39915dd49190727ac74458a28f2d00f10 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 30 Mar 2012 14:39:07 +0200 Subject: [PATCH 3/7] add the option to only load apps of a specific type --- apps/files_archive/appinfo/info.xml | 3 ++ apps/files_encryption/appinfo/info.xml | 3 ++ apps/files_remote/appinfo/info.xml | 3 ++ apps/files_sharing/appinfo/info.xml | 3 ++ files/ajax/download.php | 3 ++ files/ajax/list.php | 3 ++ files/ajax/mimeicon.php | 3 ++ files/webdav.php | 3 ++ lib/app.php | 51 +++++++++++++++++++++++--- lib/base.php | 7 +++- 10 files changed, 76 insertions(+), 6 deletions(-) diff --git a/apps/files_archive/appinfo/info.xml b/apps/files_archive/appinfo/info.xml index df767d39f6..236b5a64b0 100644 --- a/apps/files_archive/appinfo/info.xml +++ b/apps/files_archive/appinfo/info.xml @@ -7,4 +7,7 @@ AGPL Robin Appelman 3 + + + diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index 053044aaed..691b265bf6 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -7,4 +7,7 @@ AGPL Robin Appelman 3 + + + diff --git a/apps/files_remote/appinfo/info.xml b/apps/files_remote/appinfo/info.xml index 0720b6095b..8cf66ddbc3 100644 --- a/apps/files_remote/appinfo/info.xml +++ b/apps/files_remote/appinfo/info.xml @@ -7,4 +7,7 @@ AGPL Robin Appelman 3 + + + diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index abf847b448..8fda775520 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -8,4 +8,7 @@ Michael Gapczynski 2 + + + diff --git a/files/ajax/download.php b/files/ajax/download.php index 198069f3fa..39852613ab 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 8a414827e1..ec9ab7342d 100644 --- a/files/ajax/list.php +++ b/files/ajax/list.php @@ -1,5 +1,8 @@ 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; } diff --git a/lib/base.php b/lib/base.php index b07ac5af41..b031572f17 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 From 7552390031ee10ed5006ef927fa1f55cdd148554 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 30 Mar 2012 18:12:33 +0200 Subject: [PATCH 4/7] add path_hash to the filesystem cache --- db_structure.xml | 28 ++++++++++++++++++++++------ lib/filecache.php | 28 ++++++++++++++-------------- lib/util.php | 2 +- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/db_structure.xml b/db_structure.xml index 5eef44d8e8..82d2a731d4 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -64,6 +64,15 @@ 512 + + path_hash + text + + + true + 32 + + parent integer @@ -79,7 +88,7 @@ true - 512 + 300 @@ -159,14 +168,13 @@ 1 - + parent_index @@ -176,6 +184,14 @@ + + name_index + + name + ascending + + + parent_name_index diff --git a/lib/filecache.php b/lib/filecache.php index 280a9929db..a8c48e3f14 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/util.php b/lib/util.php index fa5b3daaab..529b6d958f 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); } /** From 011132feb33b4f7954eb5df5e2283e9c8f8ae944 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 30 Mar 2012 18:10:16 +0200 Subject: [PATCH 5/7] renaming remote storage support to External storage support to clear up naming conflict --- apps/files_external/appinfo/app.php | 11 +++++++++++ .../{files_remote => files_external}/appinfo/info.xml | 6 +++--- apps/{files_remote => files_external}/lib/ftp.php | 0 apps/{files_remote => files_external}/lib/google.php | 0 apps/{files_remote => files_external}/lib/webdav.php | 0 .../{files_remote => files_external}/tests/config.php | 0 apps/{files_remote => files_external}/tests/ftp.php | 2 +- .../{files_remote => files_external}/tests/google.php | 4 ++-- .../{files_remote => files_external}/tests/webdav.php | 2 +- apps/files_remote/appinfo/app.php | 11 ----------- 10 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 apps/files_external/appinfo/app.php rename apps/{files_remote => files_external}/appinfo/info.xml (58%) rename apps/{files_remote => files_external}/lib/ftp.php (100%) rename apps/{files_remote => files_external}/lib/google.php (100%) rename apps/{files_remote => files_external}/lib/webdav.php (100%) rename apps/{files_remote => files_external}/tests/config.php (100%) rename apps/{files_remote => files_external}/tests/ftp.php (89%) rename apps/{files_remote => files_external}/tests/google.php (94%) rename apps/{files_remote => files_external}/tests/webdav.php (89%) delete mode 100644 apps/files_remote/appinfo/app.php diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php new file mode 100644 index 0000000000..95770b44b7 --- /dev/null +++ b/apps/files_external/appinfo/app.php @@ -0,0 +1,11 @@ + + * 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_remote/appinfo/info.xml b/apps/files_external/appinfo/info.xml similarity index 58% rename from apps/files_remote/appinfo/info.xml rename to apps/files_external/appinfo/info.xml index 8cf66ddbc3..fb58297ff1 100644 --- a/apps/files_remote/appinfo/info.xml +++ b/apps/files_external/appinfo/info.xml @@ -1,8 +1,8 @@ - files_remote - Remote storage support - Mount remote storage sources + files_external + External storage support + Mount external storage sources 0.1 AGPL Robin Appelman diff --git a/apps/files_remote/lib/ftp.php b/apps/files_external/lib/ftp.php similarity index 100% rename from apps/files_remote/lib/ftp.php rename to apps/files_external/lib/ftp.php diff --git a/apps/files_remote/lib/google.php b/apps/files_external/lib/google.php similarity index 100% rename from apps/files_remote/lib/google.php rename to apps/files_external/lib/google.php diff --git a/apps/files_remote/lib/webdav.php b/apps/files_external/lib/webdav.php similarity index 100% rename from apps/files_remote/lib/webdav.php rename to apps/files_external/lib/webdav.php diff --git a/apps/files_remote/tests/config.php b/apps/files_external/tests/config.php similarity index 100% rename from apps/files_remote/tests/config.php rename to apps/files_external/tests/config.php diff --git a/apps/files_remote/tests/ftp.php b/apps/files_external/tests/ftp.php similarity index 89% rename from apps/files_remote/tests/ftp.php rename to apps/files_external/tests/ftp.php index 03633b7c0d..aa565751ba 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 similarity index 94% rename from apps/files_remote/tests/google.php rename to apps/files_external/tests/google.php index b49f9e4647..1c02894522 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 similarity index 89% rename from apps/files_remote/tests/webdav.php rename to apps/files_external/tests/webdav.php index 219fff8852..5179929054 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 02c1c3ae31..0000000000 --- a/apps/files_remote/appinfo/app.php +++ /dev/null @@ -1,11 +0,0 @@ - - * 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'; From dde5660915232102f531ba5309ad691e9932b150 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 30 Mar 2012 18:15:03 +0200 Subject: [PATCH 6/7] renamed Gallery to Pictures, still needs to be changed in the code to also reflect in the path --- apps/gallery/appinfo/app.php | 4 ++-- apps/gallery/appinfo/info.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 3e7e38301c..f7e0651275 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 19c5dc8b25..4c8c1cee24 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -1,11 +1,11 @@ gallery - Gallery + Pictures 0.4 AGPL Bartek Przybylski 2 - Gallery application for ownCloud + Dedicated pictures application From 284955573c59e91ed4cab7771487d1cebbb44262 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Fri, 30 Mar 2012 18:18:09 +0200 Subject: [PATCH 7/7] clarifying remoteStorage description --- apps/remoteStorage/appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml index 121587795d..0936bf9bd0 100644 --- a/apps/remoteStorage/appinfo/info.xml +++ b/apps/remoteStorage/appinfo/info.xml @@ -2,7 +2,7 @@ remoteStorage remoteStorage compatibility - Enables your users to use ownCloud as their remote storage for unhosted applications. + 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 the website of the unhosted movement. 0.5 AGPL or MIT Michiel de Jong