Closed Bug 665569 Opened 13 years ago Closed 13 years ago

Add GetFileFromString helper for getting File from native path or Url

Categories

(SeaMonkey :: Download & File Handling, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey2.4

People

(Reporter: iannbugzilla, Assigned: iannbugzilla)

References

Details

Attachments

(1 file)

At the moment downloadmanager.js has a helper for converting a string that could be either a native path or Url to a File.
This patch:
* Moves the helper into utilityOverlay.js so that it can be used elsewhere and renames it.
* Makes use of commandline resolveURI to simplify the helper.
* Switches some suite code to use the new helper.
Attachment #540487 - Flags: review?(neil)
Blocks: 665603
(From update of attachment 540487 [details] [diff] [review])
>       var size = null;
>       if (isExternalAttachment)
>       {
>-        var fileHandler = Services.io.getProtocolHandler("file")
>-                                     .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
>-        try
>-        {
>-          size = fileHandler.getFileFromURLSpec(url).fileSize;
bienvenu, are we guaranteed that the url of an external attachment is a file URL, and therefore the only reason to swallow the exception is in case the file (size) doesn't exist?
(In reply to comment #2)

> bienvenu, are we guaranteed that the url of an external attachment is a file
> URL, and therefore the only reason to swallow the exception is in case the
> file (size) doesn't exist?

Yes, it has to be a file url, because the external attachment header is generated by detaching an attachment. I suppose someone could fake that header and use a different kind of url, and perhaps we shouldn't swallow *that* exception.
Comment on attachment 540487 [details] [diff] [review]
GetFileFromString helper [Checked in: Comment 5]

>+  let commandLine = Components.classes["@mozilla.org/toolkit/command-line;1"]
>+                              .createInstance();
Nit: I'd prefer you to mention nsICommandLine as it's not obvious enough.
Attachment #540487 - Flags: review?(neil) → review+
Comment on attachment 540487 [details] [diff] [review]
GetFileFromString helper [Checked in: Comment 5]

http://hg.mozilla.org/comm-central/rev/bc728348268b
Attachment #540487 - Attachment description: GetFileFromString helper → GetFileFromString helper [Checked in: Comment 5]
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: