Merge branch 'master' into calendar_repeat

This commit is contained in:
Georg Ehrke 2012-06-17 08:36:26 +02:00
commit 229587a31e
10 changed files with 106 additions and 32 deletions

View File

@ -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);

View File

@ -47,6 +47,52 @@ 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));
}
}
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
* @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;
}
}

View File

@ -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();

View File

@ -1,4 +1,5 @@
<?php
session_write_close();
OC_App::loadApps();

View File

@ -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 );
}
}
}
/**

View File

@ -229,6 +229,7 @@ class OC{
}
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
OC_App::checkAppsRequirements();
}
OC_App::updateApps();

View File

@ -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){

View File

@ -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);

View File

@ -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;
@ -154,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;

View File

@ -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;
}
}