Fast-mode for files

This commit is contained in:
Aleksander Machniak 2018-12-21 09:58:40 +01:00 committed by Jeroen van Meeuwen (Kolab Systems)
parent 818649624b
commit e05d7987f6
2 changed files with 16 additions and 4 deletions

View file

@ -24,6 +24,7 @@
class kolab_storage_cache_file extends kolab_storage_cache
{
protected $extra_cols = array('filename');
protected $data_props = array('type', 'size', 'filename', 'fileid', 'uid');
/**
* Helper method to convert the given Kolab object into a dataset to be written to cache
@ -32,13 +33,22 @@ class kolab_storage_cache_file extends kolab_storage_cache
*/
protected function _serialize($object)
{
$sql_data = parent::_serialize($object);
if (!empty($object['_attachments'])) {
reset($object['_attachments']);
$sql_data['filename'] = $object['_attachments'][key($object['_attachments'])]['name'];
$file = $object['_attachments'][key($object['_attachments'])];
$object['type'] = $file['mimetype'];
$object['size'] = $file['size'];
$object['fileid'] = $file['id'];
}
$sql_data = parent::_serialize($object);
if (!empty($file)) {
$sql_data['filename'] = $file['name'];
}
return $sql_data;
}
}
}

View file

@ -421,6 +421,8 @@ class kolab_storage_folder extends kolab_storage_folder_api
}
else {
// return message part from IMAP directly
// TODO: We could improve performance if we cache part's encoding
// without 3rd argument get_message_part() will request BODYSTRUCTURE from IMAP
return $this->imap->get_message_part($msguid, $part, null, $print, $fp, $skip_charset_conv);
}
}