Closed
Bug 393342
Opened 17 years ago
Closed 17 years ago
select "save to disk" for PDF, not downloaded or saved; NS_ERROR_FILE_UNRECOGNIZED_PATH
Categories
(Toolkit :: Downloads API, defect)
Tracking
()
VERIFIED
FIXED
mozilla1.9alpha8
People
(Reporter: shaver, Assigned: jimm)
References
()
Details
Attachments
(1 file, 3 obsolete files)
(deleted),
patch
|
Gavin
:
review+
|
Details | Diff | Splinter Review |
When I click to download a PDF file and pick "save to disk" (it's the default for me, FWIW), I don't get it downloaded. I sometimes *do* get a pair of exceptions in the console, though, to read instead:
Error: [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIDownloadManager.userDownloadsDirectory]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: file:///Applications/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js :: anonymous :: line 96" data: no]
Source File: file:///Applications/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js
Line: 96
Error: uncaught exception: unknown (can't convert to string)
Started recently, possibly with today's nightly (2007082204; OS X on x86). My download dir is "/Users/shaver/Downloads" in the prefs window, and for both browser.download.dir and browser.download.downloadDir the pref value is (ahem):
browser.download.downloadDir;AAAAAAFAAAIAAQhMNCBDYWNoZQAAAAAAAAAAAAAAAAAAAAAAAADBcRzJSCsAAAAH2LoJRG93bmxvYWRzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkRMcGpWicAAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAABnNoYXZlcgAQAAgAAMFxjUkAAAARAAgAAMGpyqcAAAABAAgAB9i6AABvGQACAB9MNCBDYWNoZTpVc2VyczpzaGF2ZXI6RG93bmxvYWRzAAAOABQACQBEAG8AdwBuAGwAbwBhAGQAcwAPABIACABMADQAIABDAGEAYwBoAGUAEgAWVXNlcnMvc2hhdmVyL0Rvd25sb2FkcwATAAEvAAAVAAIADf//AAA=
HTH!
Flags: blocking-firefox3?
Updated•17 years ago
|
Target Milestone: --- → Firefox 3 M8
Version: unspecified → Trunk
Assignee | ||
Comment 1•17 years ago
|
||
I'm not on OSX, so I can't test this. I'm wondering if this is a failure in the directory services code for osx for retreiving the user's download folder. It was not used much prior to bug 308073.
http://lxr.mozilla.org/mozilla/source/toolkit/components/downloads/src/nsDownloadManager.cpp#741
Can you post the result of the two new attributes in the download manager - userDownloadsDirectory and defaultDownloadsDirectory?
var dm = Components.classes["@mozilla.org/download-manager;1"]
.getService(Components.interfaces.nsIDownloadManager);
dm.userDownloadsDirectory
dm.defaultDownloadsDirectory
dm.userDownloadsDirectory.target
dm.defaultDownloadsDirectory.target
(both should nsILocalFile)
One of these might result in the same error.
Note, browser.download.downloadDir is obsolete in Firefox, and is not used, so I'm not sure how it got set to that garbage. browser.download.dir is the pref we standardized on for custom download folder post 308073.
Reporter | ||
Comment 2•17 years ago
|
||
userDownloadsDirectory: NS_ERROR_FILE_UNRECOGNIZED_PATH (same error)
defaultDownloadsDirectory: [xpconnect wrapped (nsISupports, nsILocalFileMac, nsILocalFile, nsIFile, nsIHashable)]
user.target: NS_ERROR_FILE_UNRECOGNIZED_PATH (same error)
default.target: NS_ERROR_NOT_IMPLEMENTED from nsILocalFileMac.target
(That's not garbage, btw, it's how we encode Mac filehandles, because of pre-OS X legacy about names not being unique identifiers. Welcome to the Mac!)
Updated•17 years ago
|
Summary: select "save to disk" for PDF, not downloaded or saved; NS_ERROR_FILE_UNRECOGNIZED → select "save to disk" for PDF, not downloaded or saved; NS_ERROR_FILE_UNRECOGNIZED_PATH
Updated•17 years ago
|
Flags: blocking-firefox3? → blocking-firefox3+
Assignee | ||
Comment 3•17 years ago
|
||
Hey Mike, what's your browser.download.folderList pref?
Reporter | ||
Comment 4•17 years ago
|
||
It's set to 2.
Assignee | ||
Comment 5•17 years ago
|
||
Ok, so you're saying the funny data in your browser.download.dir is correct on the Mac? I was looking at the patch, and afaict, the code that sets that didn't really change. However, in the new userDownloadsDirectory code I've made the assumption it's a path. I think that might be the problem, I should be getting the complex value as an nsilocalfile instead.
Assignee | ||
Comment 6•17 years ago
|
||
Yes, I think that's it. Mike, if I roll a patch, would you have the time to test it out to be sure it addresses the problem? I'm not on osx so i'm unable to test this.
Assignee | ||
Comment 7•17 years ago
|
||
Assignee | ||
Updated•17 years ago
|
Attachment #278426 -
Flags: review?(gavin.sharp)
Assignee | ||
Comment 8•17 years ago
|
||
Tested on windows, works great. It would be nice if we could find someone to try it out on osx as well.
Blocks: 308073
Reporter | ||
Comment 9•17 years ago
|
||
Slightly different error now, after rebuilding with the patch, probably just line-number fuzz:
Error: [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIDownloadManager.userDownloadsDirectory]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: file:///Users/shaver/src/trunk/obj-out/dist/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js :: anonymous :: line 107" data: no]
Source File: file:///Users/shaver/src/trunk/obj-out/dist/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js
Line: 107
Assignee | ||
Comment 10•17 years ago
|
||
Mike, would you mind posting your browser.download.dir pref in here again? The first example you gave had "browser.download.downloadDir;" on the front of what appears to be valid base64 encoded data. Was that correct?
Reporter | ||
Comment 11•17 years ago
|
||
No, that was an artifact of choosing "Copy" instead of "Copy Value" in the about:config window. The pref value starts after the ;, and is
AAAAAAFAAAIAAQhMNCBDYWNoZQAAAAAAAAAAAAAAAAAAAAAAAADBcRzJSCsAAAAH2LoJRG93bmxvYWRzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkRMcGpWicAAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAABnNoYXZlcgAQAAgAAMFxjUkAAAARAAgAAMGpyqcAAAABAAgAB9i6AABvGQACAB9MNCBDYWNoZTpVc2VyczpzaGF2ZXI6RG93bmxvYWRzAAAOABQACQBEAG8AdwBuAGwAbwBhAGQAcwAPABIACABMADQAIABDAGEAYwBoAGUAEgAWVXNlcnMvc2hhdmVyL0Rvd25sb2FkcwATAAEvAAAVAAIADf//AAA=
Assignee | ||
Comment 12•17 years ago
|
||
ahh, ok, just confirming - is Users/shaver/Downloads a valid directory on your system?
Reporter | ||
Comment 13•17 years ago
|
||
With a leading / it is, yes, and it happens to be my Downloads directory of choice. :)
("/Users/shaver/Downloads")
Assignee | ||
Comment 14•17 years ago
|
||
Decoding that base64 chunk shows
"Users/shaver/Downloads"
within it, and I'm not sure if the starting '/' is implicit in these things. But if not, InitWithNativePath, which I believe is being called, has this check -
1349 else if (filePath.IsEmpty() || filePath.First() != '/')
1350 return NS_ERROR_FILE_UNRECOGNIZED_PATH;
and it's one of the few places in OSX file code that returns NS_ERROR_FILE_UNRECOGNIZED_PATH. I'm wondering if there is a missing '/' in your custom dir pref.
Reporter | ||
Comment 15•17 years ago
|
||
There's a leading slash in my pref as shown in the prefs window.
Where is InitWithNativePath being called? Inside the complex-value deserialization?
Assignee | ||
Comment 16•17 years ago
|
||
Yes, and that error code really isn't returned very often, which is why I was looking at that. I hate to be a pain but do you have any time to place a break point in GetUserDwonloadsFolder and step through it to see where the failure is actually occuring? If not I'll try to find somebody on irc that can help us out.
Comment 17•17 years ago
|
||
Comment on attachment 278426 [details] [diff] [review]
custom download folder patch v.1
> I'm wondering if there is a missing '/' in your custom dir pref.
Isn't the call to InitWithNativePath returning that error because you're passing it the base64 encoded string?
Anyhow, some review comments:
>Index: toolkit/components/downloads/src/nsDownloadManager.cpp
> if (customDirectory) {
>- nsCOMPtr<nsILocalFile> aFile =
>- do_CreateInstance("@mozilla.org/file/local;1", &rv);
Glad you're removing this, using an "a" prefix for local variables is just confusing :)
>+ customDirectory->Exists(&bRes);
> if (bRes) {
>- NS_ADDREF(*aResult = aFile);
>+ NS_ADDREF(*aResult = customDirectory);
> return NS_OK;
> }
>- rv = aFile->Create(nsIFile::DIRECTORY_TYPE, 755);
>+ rv = customDirectory->Create(nsIFile::DIRECTORY_TYPE, 755);
> NS_ENSURE_SUCCESS(rv, rv);
> if (bRes) {
>- NS_ADDREF(*aResult = aFile);
>+ NS_ADDREF(*aResult = customDirectory);
> return NS_OK;
> }
This second block of code you're changing looks dead - bRes can't be true here, otherwise you would have returned in the previous block. It looks like perhaps you meant to include another Exists() call before checking it, but even then Exists() shouldn't return false after a succesful Create() call. Seems like you should just remove the second "if (bRes)" (or rewrite it so that the Create() call is in a (!bRes) block rather than returning early, for clarity).
This patch does fix the problem for me, though, so r+, but please do either attach a new patch here that includes the dead code removal, or file a bug to remove it separately.
Attachment #278426 -
Flags: review?(gavin.sharp) → review+
Comment 18•17 years ago
|
||
And it'd sure be nice to have some tests for for existent and non-existent "download dirs". The latter would have caught the dead code bug, I believe, by causing that method to return the default download dir when it creates the directory.
Flags: in-testsuite?
Assignee | ||
Comment 19•17 years ago
|
||
Attachment #278426 -
Attachment is obsolete: true
Assignee | ||
Comment 20•17 years ago
|
||
(removed an uneeded rv =)
Gavin, on the tests, I've not had the chance to write one of those. The purpose would be to check to make sure the directory returned was valid?
Attachment #278605 -
Attachment is obsolete: true
Assignee | ||
Updated•17 years ago
|
Attachment #278606 -
Flags: review?(beltzner)
Comment 21•17 years ago
|
||
(In reply to comment #20)
> Created an attachment (id=278606) [details]
> custom download folder patch v.2
I don't think this is correct either - removing the rv checking for both calls makes the problem worse (one or both could fail while bRes remains true). I do think you want to go with the first patch, but just additionally remove the second "if (bRes)" check.
> Gavin, on the tests, I've not had the chance to write one of those. The
> purpose would be to check to make sure the directory returned was valid?
Right, just verifying that the nsIFile you get back from the call to GetUserDownloadsDirectory() is correct for various values of the pref. Perhaps Shawn can help with this, he probably knows the DM tests best.
Comment 22•17 years ago
|
||
Comment on attachment 278606 [details] [diff] [review]
custom download folder patch v.2
Beltzner doesn't do code reviews, and this doesn't need any additional (ui-)review once my comments are addressed.
Attachment #278606 -
Flags: review?(beltzner)
Assignee | ||
Comment 23•17 years ago
|
||
Attachment #278606 -
Attachment is obsolete: true
Updated•17 years ago
|
Attachment #278611 -
Flags: review+
Updated•17 years ago
|
Assignee: nobody → jmathies
Comment 24•17 years ago
|
||
Landed on the trunk.
mozilla/browser/components/preferences/main.js 1.11
mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp 1.110
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
I can confirm that in the 2007-08-22-04 builds of Minefield on OS X 10.4, with a 'Users/stephend/Downloads/' directory, and the pref to prompt me where to save, I get the following exception thrown:
Error: [Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIDownloadManager.userDownloadsDirectory]" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS frame :: file:///Applications/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js :: anonymous :: line 96" data: no]
Source File: file:///Applications/Minefield.app/Contents/MacOS/components/nsHelperAppDlg.js
Line: 96
With the latest Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.9a8pre) Gecko/2007090204 Minefield/3.0a8pre build, I can successfully save to 'Users/stephend/Downloads,' with no exceptions thrown.
shaver: thanks for logging this bug!
Verified FIXED
Status: RESOLVED → VERIFIED
Updated•16 years ago
|
Product: Firefox → Toolkit
You need to log in
before you can comment on or make changes to this bug.
Description
•