Closed Bug 127995 Opened 23 years ago Closed 21 years ago

Show the size of the attachments in show_bug.cgi


(Bugzilla :: Creating/Changing Bugs, enhancement, P3)




Bugzilla 2.18


(Reporter: jdahlin, Assigned: dswegen)



(1 file, 4 obsolete files)

It could sometimes be good to know how big the attachments are.
For example when you are on a slow link and don't want to download 300k+ diffs.
Now how come nobody's thought of that before?  That'd be sweet. :)  (piece of
cake to implement, too)
Severity: minor → enhancement
OS: Linux → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → Bugzilla 2.18
This patch applies cleanly to 2.17.1 and CVS tip, but has only been tested
against 2.17.1.
This patch applies cleanly to 2.17.1 and CVS tip, but has only been tested
against 2.17.1.
Attachment #126814 - Attachment is obsolete: true
I've got patches to show size in View All attachments mode and Edit attachment
mode too. I'll be submitting them during the next couple of days.
Attached patch Patch to show attachment sizes (obsolete) — Splinter Review
This patch will show attachment sizes in edit_bug, View All attachments and
Edit attachment. Tested against 2.17.1, applies cleanly (with some fuzz)
against CVS tip, but not tested.
Attachment #126815 - Attachment is obsolete: true
Attachment #126819 - Flags: review?(myk)
Comment on attachment 126819 [details] [diff] [review]
Patch to show attachment sizes

>--- bugzilla/	2003-02-07 10:30:01.000000000 +0000
>+++	2003-07-01 13:55:25.000000000 +0100

>+sub unitconvert {

I suggest turning this into a template filter.	It'll save you having to "use
Attachment" in attachment.cgi just for this function.  Also, it separates the
data from its presentation, storing the original values in the internal Perl
data structures while displaying the human-readable values via the templates. 
That makes the values reusable in other contexts while putting the
presentation-layer data manipulation into the templates where (most of) the
rest of it is located.

>--- bugzilla/template/en/default/attachment/edit.html.tmpl	2003-02-07 10:30:08.000000000 +0000
>+++	2003-07-01 13:55:51.000000000 +0100
>@@ -157,6 +157,7 @@
>         <b>Filename:</b><br>
>           <input type="text" size="20" name="filename" value="[% filename FILTER html %]"><br>
>+	<br><b>Filesize:</b> [% datasize %]<br><br>

Since you use "size" in the "show bug" screen, and since no other size makes
sense on this screen, use just "Size:" instead of "Filesize:" to label this
value.	Also, use only single breaks around the line to conform with the style
of the rest of the form.

>--- bugzilla/template/en/default/attachment/list.html.tmpl	2003-02-07 10:30:08.000000000 +0000
>+++	2003-07-01 13:55:51.000000000 +0100

>@@ -25,6 +26,7 @@
>     <th bgcolor="#cccccc" align="left">Attachment</th>
>     <th bgcolor="#cccccc" align="left">Type</th>
>     <th bgcolor="#cccccc" align="left">Created</th>
>+    <th bgcolor="#cccccc" align="left">Size</th>
>     [% IF show_attachment_flags %]
>       <th bgcolor="#cccccc" align="left">Flags</th>
>     [% END %]

When flags are being displayed, the "Size" and "Flags" values appear in each
other's columns.
Attachment #126819 - Flags: review?(myk) → review-
This patch should show attachment sizes in all relevant screens. However, since
I don't have an install that does all the new patch diff stuff I haven't been
able to test against that feature. Should it turn out that it breaks the patch
(or makes it incomplete) someone else will probably have to take over this
Attachment #126819 - Attachment is obsolete: true
Attachment #134022 - Flags: review?(myk)
Gah! Forgot to add myself to the various credits lists. If this does get
approved could whoever ends up checking it in please do that?
Comment on attachment 134022 [details] [diff] [review]
Patch to show attachment sizes (against tip)

Except for one trivial conflict this applies to the tip, looks good, and works
well. r=myk
Attachment #134022 - Flags: review?(myk) → review+
Attachment #134022 - Attachment is obsolete: true
Attachment #140669 - Flags: review?(myk)
Assignee: myk → dswegen
Attachment #140669 - Flags: review?(myk) → review+
Flags: approval+
The unitconvert function has a localisation problem. Not all languages use MB,
KB, bytes. Also, the name is too generic for what it does.

I'm not quite sure how to solve this one. Could we define the names and
abbreviations in a template hash, and then pass that hash to the unitconvert
filter? I don't think filters take parameters...

Re: Function name: fsize_convert is perhaps a tad clearer

Re: Localisation: The only way I can think of doing it is by putting the size
labels into a hash defined in a template. Then by splitting the output from the
filter and using the label ('GB'. 'bytes' etc) as lookups into the template hash.

So $bytes -> FILTER -> split -> $value, $quantfier -> print "$value
$tthash{$quantifier}", if that makes any sense. Somewhat grotty, but it should work.

If I also have to come up with a way to deal with using commas vs dots in values
I think I'll give up and go to bed :)
MB, KB, and bytes are computer terms which, although English, tend to be
recognized internationally, even when localities have alternates.  I'd wait to
hear from localizers before deciding this is a problem and working out a
solution for it.  In the meantime, go ahead and check this in.
Ah, Dave doesn't have checkin privileges.  Checking in for him:

Checking in;
/cvsroot/mozilla/webtools/bugzilla/,v  <--
new revision: 1.15; previous revision: 1.14
Checking in attachment.cgi;
/cvsroot/mozilla/webtools/bugzilla/attachment.cgi,v  <--  attachment.cgi
new revision: 1.51; previous revision: 1.50
Checking in;
/cvsroot/mozilla/webtools/bugzilla/,v  <--
new revision: 1.261; previous revision: 1.260
Checking in Bugzilla/;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/,v  <--
new revision: 1.15; previous revision: 1.14
Checking in t/004template.t;
/cvsroot/mozilla/webtools/bugzilla/t/004template.t,v  <--  004template.t
new revision: 1.30; previous revision: 1.29
Checking in t/008filter.t;
/cvsroot/mozilla/webtools/bugzilla/t/008filter.t,v  <--  008filter.t
new revision: 1.9; previous revision: 1.8
Checking in template/en/default/attachment/edit.html.tmpl;
 <--  edit.html.tmpl
new revision: 1.23; previous revision: 1.22
Checking in template/en/default/attachment/list.html.tmpl;
 <--  list.html.tmpl
new revision: 1.16; previous revision: 1.15
Checking in template/en/default/attachment/show-multiple.html.tmpl;
 <--  show-multiple.html.tmpl
new revision: 1.13; previous revision: 1.12
Closed: 21 years ago
Resolution: --- → FIXED
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.