- /**
- * Note, we edit everything as we do for the default case, but the
- * object is tacked on to the end in place of the extended attributes,
- * but we do a memcpy so that the object can be a binary object.
- */
- Dmsg6(100, "Type=%d DataStream=%d attrStream=%d File=%s\nattribs=%s\nattribsEx=%s",
- ff_pkt->type, data_stream, STREAM_UNIX_ATTRIBUTES_EX,
- ff_pkt->fname, attribs, ff_pkt->object);
- sd->msglen = Mmsg(sd->msg, "%ld %d %s%c%s%c%c",
- jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0);
- sd->msg = check_pool_memory_size(sd->msg, sd->msglen + ff_pkt->object_len + 1);
- memcpy(sd->msg + sd->msglen, ff_pkt->object, ff_pkt->object_len);
- sd->msglen += ff_pkt->object_len;
+ comp_len = ff_pkt->object_len;
+ ff_pkt->object_compression = 0;
+ if (ff_pkt->object_len > 1000) {
+ /* Big object, compress it */
+ int stat;
+ comp_len = ff_pkt->object_len + 1000;
+ POOLMEM *comp_obj = get_memory(comp_len);
+ stat = Zdeflate(ff_pkt->object, ff_pkt->object_len, comp_obj, comp_len);
+ if (comp_len < ff_pkt->object_len) {
+ ff_pkt->object = comp_obj;
+ ff_pkt->object_compression = 1; /* zlib level 9 compression */
+ } else {
+ /* Uncompressed object smaller, use it */
+ comp_len = ff_pkt->object_len;
+ }
+ Dmsg2(100, "Object compressed from %d to %d bytes\n", ff_pkt->object_len, comp_len);
+ }
+ sd->msglen = Mmsg(sd->msg, "%d %d %d %d %d %d %s%c%s%c",
+ jcr->JobFiles, ff_pkt->type, ff_pkt->object_index,
+ comp_len, ff_pkt->object_len, ff_pkt->object_compression,
+ ff_pkt->fname, 0, ff_pkt->object_name, 0);
+ sd->msg = check_pool_memory_size(sd->msg, sd->msglen + comp_len + 2);
+ memcpy(sd->msg + sd->msglen, ff_pkt->object, comp_len);
+ /* Note we send one extra byte so Dir can store zero after object */
+ sd->msglen += comp_len + 1;