Merge branch 'master' into remove_unused_vars

This commit is contained in:
Florin Peter 2013-05-29 20:29:09 +02:00
commit 8c6eec7a8f
2 changed files with 34 additions and 23 deletions

View File

@ -78,18 +78,21 @@ class Scanner {
$this->scanFile($parent); $this->scanFile($parent);
} }
} }
if($cacheData = $this->cache->get($file)) { $newData = $data;
if ($cacheData = $this->cache->get($file)) {
if ($checkExisting && $data['size'] === -1) {
$data['size'] = $cacheData['size'];
}
if ($data['mtime'] === $cacheData['mtime'] && if ($data['mtime'] === $cacheData['mtime'] &&
$data['size'] === $cacheData['size']) { $data['size'] === $cacheData['size']) {
$data['etag'] = $cacheData['etag']; $data['etag'] = $cacheData['etag'];
} }
// Only update metadata that has changed
$newData = array_diff($data, $cacheData);
} }
if ($checkExisting and $cacheData) { if (!empty($newData)) {
if ($data['size'] === -1) { $this->cache->put($file, $newData);
$data['size'] = $cacheData['size'];
}
} }
$this->cache->put($file, $data);
} }
return $data; return $data;
} }

View File

@ -27,6 +27,7 @@
class OC_Helper { class OC_Helper {
private static $mimetypes=array(); private static $mimetypes=array();
private static $tmpFiles=array(); private static $tmpFiles=array();
private static $mimetypeIcons = array();
/** /**
* @brief Creates an url using a defined route * @brief Creates an url using a defined route
@ -187,31 +188,38 @@ class OC_Helper {
* *
* Returns the path to the image of this file type. * Returns the path to the image of this file type.
*/ */
public static function mimetypeIcon( $mimetype ) { public static function mimetypeIcon($mimetype) {
$alias=array('application/xml'=>'code/xml'); $alias = array('application/xml' => 'code/xml');
if(isset($alias[$mimetype])) { if (isset($alias[$mimetype])) {
$mimetype=$alias[$mimetype]; $mimetype = $alias[$mimetype];
}
if (isset(self::$mimetypeIcons[$mimetype])) {
return self::$mimetypeIcons[$mimetype];
} }
// Replace slash and backslash with a minus // Replace slash and backslash with a minus
$mimetype = str_replace( "/", "-", $mimetype ); $icon = str_replace('/', '-', $mimetype);
$mimetype = str_replace( "\\", "-", $mimetype ); $icon = str_replace( '\\', '-', $icon);
// Is it a dir? // Is it a dir?
if( $mimetype == "dir" ) { if ($mimetype === 'dir') {
return OC::$WEBROOT."/core/img/filetypes/folder.png"; self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/folder.png';
return OC::$WEBROOT.'/core/img/filetypes/folder.png';
} }
// Icon exists? // Icon exists?
if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { if (file_exists(OC::$SERVERROOT.'/core/img/filetypes/'.$icon.'.png')) {
return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/'.$icon.'.png';
return OC::$WEBROOT.'/core/img/filetypes/'.$icon.'.png';
} }
//try only the first part of the filetype
$mimetype=substr($mimetype, 0, strpos($mimetype, '-')); // Try only the first part of the filetype
if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { $mimePart = substr($icon, 0, strpos($icon, '-'));
return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; if (file_exists(OC::$SERVERROOT.'/core/img/filetypes/'.$mimePart.'.png')) {
} self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/'.$mimePart.'.png';
else{ return OC::$WEBROOT.'/core/img/filetypes/'.$mimePart.'.png';
return OC::$WEBROOT."/core/img/filetypes/file.png"; } else {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/file.png';
return OC::$WEBROOT.'/core/img/filetypes/file.png';
} }
} }