attachment.size() != attachment.get_bytes().size()

Jun 27, 2010 at 11:06 AM

When reading the attachment leah_thumper.jpg in pstsdk/test/sample1.pst, the size() function returns 96808, but get_bytes().size() returns 93142. I can think of two possible explantions:

  1. attachment.size() contains not just the size of the attachment, but also the size of the metadata.
  2. Alternatively, attachment.get_bytes() is somehow failing to return all of the data.

Since the attachment appears to be uncorrupted, I'm guessing that (1) is correct. This is not inconsistent with the documentation for PidAttachSize: "Contains the size in bytes consumed by the Attachment object on the server."

Thank you very much for any information you can provide!

Cheers, Eric

Jun 27, 2010 at 4:52 PM

I'll have to look at the real mspst source on monday, but I strongly suspect your theory about the metadata is correct - the size property (0xe20) is probably the total size of the attachment node, where as the get_bytes() size returns just the data in the attachment data subnode.

Maybe const_property_object should have a method to (cheaply) expose the size of a variable length property, and attachment can have a get_data_size() method, message can have a get_body_size, get_html_body_size, etc.. basically anything that it's expected might be opened as a stream.

Jun 27, 2010 at 6:57 PM

Thank you for looking into this!

We're written quite a bit of code this week using pstsdk, and things are going well.

Jun 28, 2010 at 12:32 AM

Check out my latest commit. The new rules are to add a "has_X" method sibling methods for accessor methods which may potentially be absent, as well as "X_size" methods for any accessor which has a stream method (so you can decide if you want the stream version of not). Obviously a lot of accessors may have both. 

And feel free to submit a patch or just suggestions for accessor methods which you think are missing on message or folder.