From 22fe3cca044751b77f720b4bb5732b3897d25bc3 Mon Sep 17 00:00:00 2001 From: "ben%bengoodger.com" Date: Wed, 6 Aug 2003 20:39:23 +0000 Subject: [PATCH] b215290 - Alt+Click does not follow download folder preferences - make the call to saveURL from the Alt+Click handling pass the 'skipPrompt' flag, and also make the code in contentAreaUtils.js not overwrite existing files similar to 215194. git-svn-id: svn://10.0.0.236/trunk@145675 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 2 +- .../browser/base/content/contentAreaUtils.js | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index 1493dad01a1..280be773b0d 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -3899,7 +3899,7 @@ function handleLinkClick(event, href, linkNode) } if (event.altKey) { - saveURL(href, linkNode ? gatherTextUnder(linkNode) : ""); + saveURL(href, linkNode ? gatherTextUnder(linkNode) : "", null, true, true); return true; } diff --git a/mozilla/browser/base/content/contentAreaUtils.js b/mozilla/browser/base/content/contentAreaUtils.js index 616c50cc525..772c144692b 100644 --- a/mozilla/browser/base/content/contentAreaUtils.js +++ b/mozilla/browser/base/content/contentAreaUtils.js @@ -346,6 +346,27 @@ function foundHeaderInfo(aSniffer, aData, aSkipPrompt) // bugs. dir.append(defaultString); file = dir; + + // Since we're automatically downloading, we don't get the file picker's + // logic to check for existing files, so we need to do that here. + // + // Note - this code is identical to that in + // browser/components/downloads/content/nsHelperAppDlg.js. + // If you are updating this code, update that code too! We can't share code + // here since that code is called in a js component. + while (file.exists()) { + var parts = /.+-(\d+)(\..*)?$/.exec(file.leafName); + if (parts) { + file.leafName = file.leafName.replace(/((\d+)\.)/, + function (str, p1, part, s) { + return (parseInt(part) + 1) + "."; + }); + } + else { + file.leafName = file.leafName.replace(/\./, "-1$&"); + } + } + } if (isDocument)