Closed Bug 490930 Opened 15 years ago Closed 14 years ago

Always store attachments locally if they are over X size, don't ever display "Big File" checkbox

Categories

(Bugzilla :: Attachments & Requests, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.2

People

(Reporter: mkanat, Assigned: LpSolit)

References

Details

(Keywords: ue)

Attachments

(1 file)

The "Big File" checkbox is confusing to users for various reasons. pyrzak's students' research pointed out that it has a note next to it about data getting purged--that's something the user has no control over, so it probably shouldn't even be displayed to them.

Also, the user isn't in a position to decide whether the attachment should be stored locally or in the database--that's more something that the administrator should be deciding.

So we should probably have a single parameter called something like big_file_size, and any file over that size is automatically stored locally. It can default to some enormous number so that files are never stored locally, by default. Setting it to 0 means that all files are stored locally and never stored in the database.
The problem is that we cannot know in advance whether the attachment will be large or not. And the way we get the data is very different depending on the answer to this question.

But I agree that this "Big File" checkbox should never be displayed.
Actually, I think 0 should mean "always store in the database", since a *negative* number would logically mean "always store on the disk".
<LpSolit> mkanat: to fix it, we can no longer use $data = <$fh>, because it slurps the whole attachment at once. I would always have to store it in a tempfile first, before deciding what to do with it
<mkanat> LpSolit: Well, actually, we already always store it in a temp file first.
<mkanat> LpSolit: Because that's what CGI.pm does with it.
<mkanat> LpSolit: So that's OK, I think. 

Let's do this. :)
Assignee: attach-and-request → LpSolit
Status: NEW → ASSIGNED
Target Milestone: --- → Bugzilla 3.6
Target Milestone: Bugzilla 3.6 → Bugzilla 3.8
Target Milestone: Bugzilla 4.0 → Bugzilla 4.2
Attached patch patch, v1Splinter Review
Both parameters are still required as you don't want to store files of arbitrary size. Now that I moved the check of the file size in _check_data() (as it should be), I can copy the whole temporary file at once using File::Copy::copy(). This should be faster than looping over each line of the file.
Attachment #456331 - Flags: review?(mkanat)
Comment on attachment 456331 [details] [diff] [review]
patch, v1

This is an awesome cleanup, and looks great. :-)
Attachment #456331 - Flags: review?(mkanat) → review+
Flags: approval?
Flags: approval? → approval+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified attachment.cgi
modified post_bug.cgi
modified Bugzilla/Attachment.pm
modified docs/en/xml/using.xml
modified js/attachment.js
modified template/en/default/admin/params/attachment.html.tmpl
modified template/en/default/attachment/createformcontents.html.tmpl
modified template/en/default/global/code-error.html.tmpl
modified template/en/default/global/user-error.html.tmpl
Committed revision 7297.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Blocks: 1062746
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: