Bug 168377 - Show attachment size in editor
Summary: Show attachment size in editor
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: 2.3   Edit
Assignee: Willian Mitsuda CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on: 217008
Blocks:
  Show dependency tree
 
Reported: 2006-12-17 22:44 EST by Willian Mitsuda CLA
Modified: 2008-02-23 17:52 EST (History)
3 users (show)

See Also:


Attachments
Patch (15.75 KB, patch)
2008-01-29 17:22 EST, Willian Mitsuda CLA
no flags Details | Diff
mylyn/context/zip (16.19 KB, application/octet-stream)
2008-01-29 17:22 EST, Willian Mitsuda CLA
no flags Details
Complementary patch (4.24 KB, patch)
2008-02-22 01:09 EST, Willian Mitsuda CLA
no flags Details | Diff
mylyn/context/zip (10.89 KB, application/octet-stream)
2008-02-22 01:09 EST, Willian Mitsuda CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Willian Mitsuda CLA 2006-12-17 22:44:47 EST
Show attachment size column on attachment table from bug editor.
Comment 1 Robert Elves CLA 2007-01-02 17:01:33 EST
We don't get the attachment size in the xml although there may be a way to query for this information since it IS available in the HTLM. Either way, RepositoryAttachment should have this facility and should be exposed in the editor so that other connectors can display this info if available.
Comment 2 Mik Kersten CLA 2007-01-05 09:02:45 EST
Rob: also consider making the corresponding enhancement request to Bugzilla.
Comment 3 Robert Elves CLA 2007-01-05 12:56:58 EST
Done: https://bugzilla.mozilla.org/show_bug.cgi?id=366059
Comment 4 Willian Mitsuda CLA 2008-01-25 16:34:34 EST
FYI, I have a patch almost done. I hope to submit soon.
Comment 5 Robert Elves CLA 2008-01-26 21:23:41 EST
Great to hear Willian. Thanks for letting us know you are working on this.
Comment 6 Willian Mitsuda CLA 2008-01-29 17:22:06 EST
Created attachment 88208 [details]
Patch
Comment 7 Willian Mitsuda CLA 2008-01-29 17:22:09 EST
Created attachment 88209 [details]
mylyn/context/zip
Comment 8 Willian Mitsuda CLA 2008-01-29 17:22:38 EST
This patch adds an size attribute to repository attachment, and implements the attribute capturing for bugzilla.

The attachment table in task editor includes a new "size" column. For bugzilla < 3.0 and connectors that don't supply that attribute, an "-" is shown. Unfortunatelly, I couldn't find a way to determine if an connector have this capability, so you may end up with an bogus "Size" column filled with "-" for some cases.

The formatting is done according to the magnitude of the size value, so instead of "123456789 bytes", you read "123,46 MB". The rouding is done for 2 decimal places.

There are tests for the formatting cases, and I did manual tests in landfill.bugzilla.org for 2.22 and 3.0 bugzilla instances.
Comment 9 Steffen Pingel CLA 2008-01-29 18:38:57 EST
Great patch! 

+1 for merging
Comment 10 Robert Elves CLA 2008-02-06 20:54:53 EST
Awesome Willian! Patch applied, ip log updated.
Comment 11 Robert Elves CLA 2008-02-06 20:55:14 EST
Fixed.
Comment 12 Mik Kersten CLA 2008-02-21 00:33:59 EST
I just noticed that we're using "kB" instead of "KB", and the latter is the common capitalization.  Could we change this?  Also, there appear to be some string matches for ".. kB" which would be good to avoid.
Comment 13 Willian Mitsuda CLA 2008-02-21 00:52:22 EST
Rob changed the original patch from KB to kB. But according to wikipedia either is valid.
Comment 14 Mik Kersten CLA 2008-02-21 00:57:47 EST
Rob? Windows uses KB and afaik it is more standard given that it parallels the metric system abbreviation, so unless there's a reason to go with "kB" could we make the change?
Comment 15 Steffen Pingel CLA 2008-02-21 01:35:05 EST
I suggested this change due to the mismatch of the sizes displayed in the Bugzilla web UI. The Bugzilla web UI assumes that 1 KB = 1024 bytes whereas the task editor attachment table assumes that 1 kB = 1000 bytes. I am okay with changing it to KB but then the unit conversion should be changed as well.
Comment 16 Willian Mitsuda CLA 2008-02-21 10:09:13 EST
I decided to use 1 KB == 1000 bytes because it is easier to convert and round.

But I agree that the right approach would be to use 1024 instead of 1000 as the unit conversion, and it is what I learned in school, but thanks to HD manufacturers and their marketing department, some people tend to use 1000 bytes = 1 KB.

There is a nearly unknown standard that, for clarity, encourages the use of another family of units, and says 1024 bytes should be called 1 KiB (kibibyte).

See a more complete explanation on this blog post: http://www.codinghorror.com/blog/archives/000950.html
And the wikipedia entry: http://en.wikipedia.org/wiki/Kilobyte

This is not largely used, but I know at least 1 app, NetMeter, which I use here, that uses KiB to denote 1024 and KB to 1000.

So I changing the grouping to multiple of 1024 bytes, I think we should also change the units to KiB, MiB, GiB, to eliminate ambiguity.
Comment 17 Mik Kersten CLA 2008-02-21 17:56:23 EST
I didn't realize that this question was so interesting and had never heard of KiB's. 

When there is no clear answer, my instinct is to go with something that will meet most user's expectation but that's still accurate.  So I think that we should go with the same thing as the OS does.  For most Eclipse users is it's Windows, which in the file dialogs reports units in KB = 1024.  

Willian: you OK with this?
Comment 18 Willian Mitsuda CLA 2008-02-21 23:51:03 EST
OK, no problem.
Comment 19 Steffen Pingel CLA 2008-02-22 00:11:17 EST
If we want to go ahead with this change it should be done soon so it can go into the 2.3 release.
Comment 20 Willian Mitsuda CLA 2008-02-22 01:09:03 EST
Created attachment 90444 [details]
Complementary patch

Patch for using 1024-based units and KB instead of kB.

There is a minor issue with this approach I simply don't know how to resolve, which is for values near 1 MB, 1 GB, which when rounded to 2 decimal places are formatted to incorrect magnitude. I.e. 1048576 bytes is formatted to "1.00 MB" (exactly), but 1048575 bytes is formatted to "1024.00 KB" due to rounding up.
Comment 21 Willian Mitsuda CLA 2008-02-22 01:09:11 EST
Created attachment 90445 [details]
mylyn/context/zip
Comment 22 Steffen Pingel CLA 2008-02-22 19:24:01 EST
Patch applied and IP log updated. Thanks Willian! It's good to have this in time for the release so we don't confuse users by displaying different sizes later on.

We could change the implementation so that anything >= 1000 bytes shows up in KB, i.e. 1023 bytes would show up as 0.99 KB. I think the current implementation is consistent with the Bugzilla web interface so I'm okay with keeping it the way it is now. Do you know what Bugzilla displays for attachments that are 1048575 bytes in size?
Comment 23 Willian Mitsuda CLA 2008-02-23 15:35:57 EST
 (In reply to comment #22)
> Do you know what Bugzilla displays for attachments that are
> 1048575 bytes in size?

I have no idea what algorithm bugzilla uses for formatting.
Comment 24 Steffen Pingel CLA 2008-02-23 16:18:03 EST
Just tried it on mylyn.eclipse.org and got this error when I tried to upload a file that was 1048575 bytes in size:

The file you are trying to attach is 1024 kilobytes (KB) in size. Non-patch attachments cannot be more than 1000 KB
Comment 25 Willian Mitsuda CLA 2008-02-23 16:27:15 EST
Steffen, is this a bugzilla test installation?

AFAIK, there is a configuration in bugzilla to limit the size of attachments accepted, which by default is low.
Comment 26 Steffen Pingel CLA 2008-02-23 17:52:42 EST
Yes, it's the repository on mylyn.eclipse.org. I should have added that the size in the error message seems to be consistent with your comment #20, so it's all good :).