From 9c6d82d00d4280f1b87fe077abff0b4be1d9e07c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 16 Jun 2012 19:48:33 +0200 Subject: [PATCH 01/11] PDF Viewer: Double encode link. --- apps/files_pdfviewer/js/viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_pdfviewer/js/viewer.js b/apps/files_pdfviewer/js/viewer.js index d98bedc5c0..2c9cbb9b43 100644 --- a/apps/files_pdfviewer/js/viewer.js +++ b/apps/files_pdfviewer/js/viewer.js @@ -13,7 +13,7 @@ function hidePDFviewer() { function showPDFviewer(dir,filename){ if(!showPDFviewer.shown){ $("#editor").hide(); - var url = OC.filePath('files','ajax','download.php')+'?files='+encodeURIComponent(filename)+"&dir="+encodeURIComponent(dir); + var url = OC.filePath('files','ajax','download.php')+encodeURIComponent('?files='+encodeURIComponent(filename)+"&dir="+encodeURIComponent(dir)); $('table').hide(); function im(path) { return OC.filePath('files_pdfviewer','js','pdfjs/web/images/'+path); } showPDFviewer.oldcode = $("#controls").html(); From 99a68abbd5ae5b41b0fcae5efc8235ac49484164 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 16 Jun 2012 14:15:43 +0200 Subject: [PATCH 02/11] Add session_write_close to the minimizer --- core/minimizer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/minimizer.php b/core/minimizer.php index 6828acc87d..709c7508e9 100644 --- a/core/minimizer.php +++ b/core/minimizer.php @@ -1,4 +1,5 @@ Date: Sat, 16 Jun 2012 20:50:52 +0200 Subject: [PATCH 03/11] Only check for apps owncloud version requirment when there is a new owncloud version --- lib/app.php | 29 +++++++++++++++-------------- lib/base.php | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/app.php b/lib/app.php index 7fdfc93138..c08e977b03 100755 --- a/lib/app.php +++ b/lib/app.php @@ -489,32 +489,33 @@ class OC_App{ $currentVersion=OC_App::getAppVersion($app); if ($currentVersion) { if (version_compare($currentVersion, $installedVersion, '>')) { - OC_Log::write($app,'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG); + OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion,OC_Log::DEBUG); OC_App::updateApp($app); - OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app)); + OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app)); } } } + } - // check if the current enabled apps are compatible with the current ownCloud version. disable them if not. - // this is important if you upgrade ownCloud and have non ported 3rd party apps installed - $apps =OC_App::getEnabledApps(); - $version=OC_Util::getVersion(); + /** + * check if the current enabled apps are compatible with the current + * ownCloud version. disable them if not. + * This is important if you upgrade ownCloud and have non ported 3rd + * party apps installed. + */ + public static function checkAppsRequirements($apps = array()){ + if (empty($apps)) { + $apps = OC_App::getEnabledApps(); + } + $version = OC_Util::getVersion(); foreach($apps as $app) { - // check if the app is compatible with this version of ownCloud - $info=OC_App::getAppInfo($app); + $info = OC_App::getAppInfo($app); if(!isset($info['require']) or ($version[0]>$info['require'])){ OC_Log::write('core','App "'.$info['name'].'" can\'t be used because it is not compatible with this version of ownCloud',OC_Log::ERROR); OC_App::disable( $app ); } - - - } - - - } /** diff --git a/lib/base.php b/lib/base.php index fedc123885..30f7e5bba6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -229,6 +229,7 @@ class OC{ } OC_Config::setValue('version',implode('.',OC_Util::getVersion())); + OC_App::checkAppsRequirements(); } OC_App::updateApps(); From 6f93176a4be21dcda1009d9cea052e5fdb50ae16 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 16 Jun 2012 20:52:01 +0200 Subject: [PATCH 04/11] Be smarter when checking single app language availability --- lib/l10n.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/l10n.php b/lib/l10n.php index 3596c992ba..ba4bf23780 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -228,23 +228,29 @@ class OC_L10N{ return self::$language; } - $available = array(); - if(is_array($app)){ - $available = $app; - } - else{ - $available=self::findAvailableLanguages($app); - } if(OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')){ $lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang'); self::$language = $lang; - if(array_search($lang, $available) !== false){ + if(is_array($app)){ + $available = $app; + $lang_exists = array_search($lang, $available) !== false; + } + else { + $lang_exists = self::languageExists($app, $lang); + } + if($lang_exists){ return $lang; } } if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ $accepted_languages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + if(is_array($app)){ + $available = $app; + } + else{ + $available = self::findAvailableLanguages($app); + } foreach($accepted_languages as $i){ $temp = explode(';', $i); if(array_search($temp[0], $available) !== false){ @@ -296,4 +302,15 @@ class OC_L10N{ } return $available; } + + public static function languageExists($app, $lang){ + if ($lang == 'en'){//english is always available + return true; + } + $dir = self::findI18nDir($app); + if(is_dir($dir)){ + return file_exists($dir.'/'.$lang.'.php'); + } + return false; + } } From b38e46276f247315772c5d46f0c73ea11a139cef Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 01:26:30 +0200 Subject: [PATCH 05/11] when checking if the content of a folder has been updated, exlicitly state that we are checking a folder solves some issues with external storages not updating correctly --- lib/filecache.php | 2 +- lib/filecache/update.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/filecache.php b/lib/filecache.php index 32c6929ff6..9963a5a3ba 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -217,7 +217,7 @@ class OC_FileCache{ * - versioned */ public static function getFolderContent($path,$root=false,$mimetype_filter=''){ - if(OC_FileCache_Update::hasUpdated($path,$root)){ + if(OC_FileCache_Update::hasUpdated($path,$root,true)){ OC_FileCache_Update::updateFolder($path,$root); } return OC_FileCache_Cached::getFolderContent($path,$root,$mimetype_filter); diff --git a/lib/filecache/update.php b/lib/filecache/update.php index 9e23c6dfe7..2e3eb67da0 100644 --- a/lib/filecache/update.php +++ b/lib/filecache/update.php @@ -15,9 +15,10 @@ class OC_FileCache_Update{ * check if a file or folder is updated outside owncloud * @param string path * @param string root (optional) + * @param boolean folder * @return bool */ - public static function hasUpdated($path,$root=false){ + public static function hasUpdated($path,$root=false,$folder=false){ if($root===false){ $view=OC_Filesystem::getView(); }else{ @@ -29,7 +30,11 @@ class OC_FileCache_Update{ $cachedData=OC_FileCache_Cached::get($path,$root); if(isset($cachedData['mtime'])){ $cachedMTime=$cachedData['mtime']; - return $view->hasUpdated($path,$cachedMTime); + if($folder){ + return $view->hasUpdated($path.'/',$cachedMTime); + }else{ + return $view->hasUpdated($path,$cachedMTime); + } }else{//file not in cache, so it has to be updated if(($path=='/' or $path=='') and $root===false){//dont auto update the home folder, it will be scanned return false; From e8dd86ce0de9ec0d7c1774c62281451445b26c92 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 16 Jun 2012 19:48:03 -0400 Subject: [PATCH 06/11] Revert "Set default charset to utf-8." This reverts commit 709dbd82a60363555b613b381f73d942f9fdbcc4. --- lib/db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/db.php b/lib/db.php index a0ad499b60..bcc8657b4a 100644 --- a/lib/db.php +++ b/lib/db.php @@ -120,7 +120,7 @@ class OC_DB { }else{ $dsn='mysql:dbname='.$name.';host='.$host; } - $opts[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'UTF8'; SET CHARACTER SET 'UTF8';"; + $opts[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES 'UTF8'"; break; case 'pgsql': if($port){ From 549541215e41cc42d94ae92f72df423fce1e5a1c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 02:15:11 +0200 Subject: [PATCH 07/11] get the correct metadate from updated folders to put in the cache --- lib/filecache/update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/filecache/update.php b/lib/filecache/update.php index 2e3eb67da0..dd77f491ca 100644 --- a/lib/filecache/update.php +++ b/lib/filecache/update.php @@ -159,9 +159,9 @@ class OC_FileCache_Update{ foreach($cachedContent as $file){ $size+=$file['size']; } - $mtime=$view->filemtime($path); - $ctime=$view->filectime($path); - $writable=$view->is_writable($path); + $mtime=$view->filemtime($path.'/'); + $ctime=$view->filectime($path.'/'); + $writable=$view->is_writable($path.'/'); OC_FileCache::put($path,array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype,'writable'=>$writable)); }else{ $count=0; From 5b6229544d03e59085918151abd010f2700b84f2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 02:42:40 +0200 Subject: [PATCH 08/11] fix statcache for filenames containing non-alphanumeric characters in smb streamwrapper --- 3rdparty/smb4php/smb.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/3rdparty/smb4php/smb.php b/3rdparty/smb4php/smb.php index 69fb2487bc..12c5890723 100644 --- a/3rdparty/smb4php/smb.php +++ b/3rdparty/smb4php/smb.php @@ -326,8 +326,11 @@ class smb_stream_wrapper extends smb { $this->dir = array_keys($o['info']); $this->dir_index = 0; $this->adddircache ($url, $this->dir); + if(substr($url,-1,1)=='/'){ + $url=substr($url,0,-1); + } foreach ($o['info'] as $name => $info) { - smb::addstatcache($url . '/' . urlencode($name), $info); + smb::addstatcache($url . '/' . $name, $info); } } else { trigger_error ("dir_opendir(): dir failed for path '".$pu['path']."'", E_USER_WARNING); From 769cbe9a4cc5b105cc0277057b21e4661bd9c890 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 02:54:23 +0200 Subject: [PATCH 09/11] improve filecache support for smb --- apps/files_external/lib/smb.php | 44 ++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 9112655194..e05d69f784 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -47,6 +47,48 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ $path=substr($path,0,-1); } return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path; - + } + + public function stat($path){ + if(!$path and $this->root=='/'){//mtime doesn't work for shares + $mtime=$this->shareMTime(); + $stat=stat($this->constructUrl($path)); + $stat['mtime']=$mtime; + return $stat; + }else{ + return stat($this->constructUrl($path)); + } + } + + /** + * check if a file or folder has been updated since $time + * @param int $time + * @return bool + */ + public function hasUpdated($path,$time){ + if(!$path and $this->root=='/'){ + //mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough + return true; + }else{ + $actualTime=$this->filemtime($path); + return $actualTime>$time; + } + } + + /** + * get the best guess for the modification time of the share + */ + private function shareMTime(){ + $dh=$this->opendir(''); + $lastCtime=0; + while($file=readdir($dh)){ + if($file!='.' and $file!='..'){ + $ctime=$this->filemtime($file); + if($ctime>$lastCtime){ + $lastCtime=$ctime; + } + } + } + return $lastCtime; } } From ed66c63c29c71c183093b7d34133b4cfb5d64925 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 02:59:38 +0200 Subject: [PATCH 10/11] improve caching smb results a bit --- apps/files_external/lib/smb.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index e05d69f784..9db8e9fd98 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -60,6 +60,10 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ } } + public function filetype($path){ + return (bool)$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go + } + /** * check if a file or folder has been updated since $time * @param int $time From ad4f066bac5e4d6777b258d6a161ab062211d787 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Jun 2012 03:09:49 +0200 Subject: [PATCH 11/11] suppress error when using is_dir on non directory in smb backend --- apps/files_external/lib/smb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 9db8e9fd98..5e34deb233 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -61,7 +61,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ } public function filetype($path){ - return (bool)$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go + return (bool)@$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go } /**