From e05d7987f62168e88811d751b9f21c12a86653b4 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 21 Dec 2018 09:58:40 +0100 Subject: [PATCH] Fast-mode for files --- .../libkolab/lib/kolab_storage_cache_file.php | 18 ++++++++++++++---- plugins/libkolab/lib/kolab_storage_folder.php | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/libkolab/lib/kolab_storage_cache_file.php b/plugins/libkolab/lib/kolab_storage_cache_file.php index ea1823d6..053438c1 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_file.php +++ b/plugins/libkolab/lib/kolab_storage_cache_file.php @@ -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; } -} \ No newline at end of file +} diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 02ac6adf..1ffbb457 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -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); } }