summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-11-08 12:47:53 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2012-11-08 12:47:53 (GMT)
commitfa6b80b46338306413b108445f02aaf38653a9dc (patch)
tree32fe82bafa186c6696279086264379f308d83332
parente292aec5dcc71cbac4f79abf0ee3bae494c3d91b (diff)
downloadroundcubemail-plugins-kolab-fa6b80b46338306413b108445f02aaf38653a9dc.tar.gz
Make sure attachments information stored in cache contain attachment size
-rw-r--r--plugins/libkolab/lib/kolab_storage_folder.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index 461125b..7c28eff 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -570,10 +570,22 @@ class kolab_storage_folder
}
}
- // generate unique keys (used as content-id) for attachments
+ // Parse attachments
if (is_array($object['_attachments'])) {
$numatt = count($object['_attachments']);
foreach ($object['_attachments'] as $key => $attachment) {
+ // make sure size is set, so object saved in cache contains this info
+ if (!isset($attachment['size'])) {
+ if (!empty($attachment['content'])) {
+ $attachment['size'] = strlen($attachment['content']);
+ }
+ else if (!empty($attachment['path'])) {
+ $attachment['size'] = filesize($attachment['path']);
+ }
+ $object['_attachments'][$key] = $attachment;
+ }
+
+ // generate unique keys (used as content-id) for attachments
if (is_numeric($key) && $key < $numatt) {
// derrive content-id from attachment file name
$ext = preg_match('/(\.[a-z0-9]{1,6})$/i', $attachment['name'], $m) ? $m[1] : null;