plugins/libkolab

Aleksander Machniak machniak at kolabsys.com
Thu Nov 8 13:48:41 CET 2012


 plugins/libkolab/lib/kolab_storage_folder.php |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit fa6b80b46338306413b108445f02aaf38653a9dc
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Nov 8 13:47:53 2012 +0100

    Make sure attachments information stored in cache contain attachment size

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;





More information about the commits mailing list