Save as dialog won't open on known sites after copying profile from linux to windows

RESOLVED FIXED in Firefox 58

Status

()

RESOLVED FIXED
3 years ago
a year ago

People

(Reporter: agnag1+bugzilla, Assigned: Kwan, Mentored)

Tracking

44 Branch
Firefox 58
x86_64
Windows 10
Points:
---

Firefox Tracking Flags

(firefox58 fixed)

Details

(Whiteboard: [lang=js][good next bug])

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160308181531

Steps to reproduce:

Use Firefox on Linux, save content from various websites to different folders, so the prefered location is saved (and different from the default)

Copy the whole profile folder including profile.ini to the Windows PC.

* Set download preference to ask for target folder on every file
* Go to one of the previous known sites, download something
* The Download dialog appears (open with / save file)
* Save file, click OK.


How I FIXED it: clear recent History
Time range: Everything
Details: Check (only) Site preferences

The culprit most likely is the different Path naming scheme between Windows and Linux

C:/Users/Name/ vs.
/home/name/


Actual results:

* The pre-download Dialog closes as expected, but the "save as" Dialog does not open, nor does the file download. 


Expected results:

Save file Dialog opening with default download location
(Reporter)

Updated

3 years ago
OS: Unspecified → Windows 10
Hardware: Unspecified → x86_64

Updated

3 years ago
Component: Untriaged → Preferences

Comment 1

3 years ago
Paolo, where is this information saved? ISTR looking at a bug like this before, but I don't recall off-hand how I'd find it back again.

(Either way, it's per-site, so this isn't a preferences bug -> back to untriaged)
Component: Preferences → Untriaged
Flags: needinfo?(paolo.mozmail)

Comment 2

3 years ago
It's saved in ContentPrefs, might be simple to fix.
Flags: needinfo?(paolo.mozmail)

Comment 3

3 years ago
ni -> me to figure out at least half of this and make it a mentored bug.
Component: Untriaged → Downloads Panel
Flags: needinfo?(gijskruitbosch+bugs)

Comment 4

3 years ago
Yeah, I can reproduce this on Windows, at least. The following errors show up in the browser console:

NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath] DownloadLastDir.jsm:167:0
[Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath]"  nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)"  location: "JS frame :: resource://gre/modules/DownloadLastDir.jsm :: DownloadLastDir.prototype.getFileAsync/<.handleCompletion :: line 167"  data: no] ContentPrefUtils.jsm:50:0


The basic fix here should be to make DownloadLastDir catch exceptions like this and return the default instead.

In order to reproduce if you don't have a profile to copy, follow these steps:

0. clean profile, set downloads to always ask for a directory

1. go to http://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/

2. open the browser (not web) console:

3. Run:

cps2 = Services.contentPrefs.QueryInterface(Ci.nsIContentPrefService2);

cps2.set("archive.mozilla.org", "browser.download.lastDir", "/this/is/bogus", {usePrivateBrowsing: false})

4. Run:

cps2.getByDomainAndName("archive.mozilla.org", "browser.download.lastDir", {usePrivateBrowsing: false}, {handleCompletion() { console.log('done')}, handleResult(cp) { console.log(cp) }})

and verify that the value of the content pref matches the 'this/is/bogus' thing you just assigned.

5. Try to download one of the files that prompt a download, e.g. http://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-48.0a1.en-US.linux-i686.checksums .

6. click 'save' if prompted to open/save

7. You should see a 'save file as' dialog. Instead you see nothing and you get the errors above in the browser console.

Fixing this would involve wrapping both:

https://dxr.mozilla.org/mozilla-central/rev/55d557f4d73ee58664bdf2fa85aaab555224722e/toolkit/mozapps/downloads/DownloadLastDir.jsm#124

and this:

https://dxr.mozilla.org/mozilla-central/rev/55d557f4d73ee58664bdf2fa85aaab555224722e/toolkit/mozapps/downloads/DownloadLastDir.jsm#163-167

in try...catch blocks, and ensuring that "lastDirFile" (in the first case) and "file" in the seocnd case end up being null.
Mentor: gijskruitbosch+bugs
Flags: needinfo?(gijskruitbosch+bugs)
Whiteboard: [lang=js]

Updated

3 years ago
Duplicate of this bug: 1010220

Updated

3 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [lang=js] → [lang=js][good next bug]

Comment 6

2 years ago
I confirm this is happening after migrating Windows -> Linux.  Only happens with saving https pages.

NS_ERROR_FILE_UNRECOGNIZED_PATH: Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath]DownloadLastDir.jsm:167
[Exception... "Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath]"  nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)"  location: "JS frame :: resource://gre/modules/DownloadLastDir.jsm :: DownloadLastDir.prototype.getFileAsync/<.handleCompletion :: line 167"  data: no]
DownloadLastDir.prototype.getFileAsync/<.handleCompletion()
DownloadLastDir.jsm:167
safeCallback()
ContentPrefUtils.jsm:47
cbHandleCompletion()
ContentPrefUtils.jsm:36
onDone()
ContentPrefService2.jsm:154
handleCompletion()
ContentPrefService2.jsm:750
(unknown)
(Assignee)

Comment 7

a year ago
(In reply to :Gijs from comment #4)
> cps2 = Services.contentPrefs.QueryInterface(Ci.nsIContentPrefService2);

Just as a note this results in "TypeError: Services.contentPrefs is undefined" on nightly now for some reason.  Still works on 55, but .get... fails with [Exception... "Failure arg 2 [nsIContentPrefService2.getByDomainAndName]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1"  data: no]
Fortunately ubuntu comes with a nice SQLite DB browser that lets one edit to reproduce.

> https://dxr.mozilla.org/mozilla-central/rev/
> 55d557f4d73ee58664bdf2fa85aaab555224722e/toolkit/mozapps/downloads/
> DownloadLastDir.jsm#124

Fortunately obsolete now.
 
> https://dxr.mozilla.org/mozilla-central/rev/
> 55d557f4d73ee58664bdf2fa85aaab555224722e/toolkit/mozapps/downloads/
> DownloadLastDir.jsm#163-167

Done.

> ensuring that [...] "file" [...] end up being null.

I went for putting it back to plainPrefFile, so that there was no behaviour difference between having no pref, and finding an invalid one.  Let me know if you'd prefer null though.
Assignee: nobody → moz-ian
Status: NEW → ASSIGNED
Comment hidden (mozreview-request)

Comment 9

a year ago
(In reply to Ian Moody [:Kwan] from comment #7)
> (In reply to :Gijs from comment #4)
> > cps2 = Services.contentPrefs.QueryInterface(Ci.nsIContentPrefService2);
> 
> Just as a note this results in "TypeError: Services.contentPrefs is
> undefined" on nightly now for some reason.

It's because the Services.contentPrefs alias got rm'd, apparently.

>  Still works on 55, but .get...
> fails with [Exception... "Failure arg 2
> [nsIContentPrefService2.getByDomainAndName]"  nsresult: "0x80004005
> (NS_ERROR_FAILURE)"  location: "JS frame :: debugger eval code ::
> <TOP_LEVEL> :: line 1"  data: no]
> Fortunately ubuntu comes with a nice SQLite DB browser that lets one edit to
> reproduce.

contentPrefs = Components.classes["@mozilla.org/content-pref/service;1"]
                         .getService(Components.interfaces.nsIContentPrefService2);

contentPrefs.getByDomainAndName("archive.mozilla.org", "browser.download.lastDir", null, {handleCompletion: f => console.log('completion', f), handleResult: f => console.log('value', f.value) });

produces something sane.

Anyway, tested with this and it seems to work. :-)

Comment 10

a year ago
mozreview-review
Comment on attachment 8913971 [details]
Bug 1258797 - Catch error when trying to open save as dialog to invalid path.

https://reviewboard.mozilla.org/r/185342/#review190300
Attachment #8913971 - Flags: review?(gijskruitbosch+bugs) → review+

Comment 11

a year ago
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/e900a3d074b8
Catch error when trying to open save as dialog to invalid path. r=Gijs
Backed out for failing eslint at toolkit/mozapps/downloads/DownloadLastDir.jsm:150:

https://hg.mozilla.org/integration/autoland/rev/562b8f9ed39c21bbb30e75fdff6376ff18b3fd9e

Push with failure: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=e900a3d074b81b7617e6a65bcd18a02450652990&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=usercancel&filter-resultStatus=runnable
Failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=134215744&repo=autoland
> TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/toolkit/mozapps/downloads/DownloadLastDir.jsm:150:11 | Closing curly brace does not appear on the same line as the subsequent block. (brace-style)
Flags: needinfo?(moz-ian)
Comment hidden (mozreview-request)
(Assignee)

Comment 14

a year ago
Whoops, sorry, forgot about eslint, and after I went to all the trouble of setting it up way back when.

Anyway, fixed:
>$ mach eslint toolkit/mozapps/downloads/DownloadLastDir.jsm
>✖ 0 problems (0 errors, 0 warnings)
Flags: needinfo?(moz-ian)
Keywords: checkin-needed

Comment 15

a year ago
Pushed by gijskruitbosch@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/972c3948109e
Catch error when trying to open save as dialog to invalid path. r=Gijs
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/972c3948109e
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
status-firefox58: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
You need to log in before you can comment on or make changes to this bug.