After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 326312 - does not detect if download file already exists locally
does not detect if download file already exists locally
Status: RESOLVED OBSOLETE
Product: epiphany
Classification: Core
Component: Downloads
git master
Other All
: Normal enhancement
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks: 755382
 
 
Reported: 2006-01-09 15:58 UTC by Guilherme de Siqueira Pastore
Modified: 2018-08-03 19:15 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
first attempt for a fix (10.60 KB, patch)
2007-09-04 15:10 UTC, Cosimo Cecchi
needs-work Details | Review

Description Guilherme de Siqueira Pastore 2006-01-09 15:58:06 UTC
As mentioned on http://bugzilla.gnome.org/show_bug.cgi?id=138876#c9, downloading a file which has already been downloaded should not be necessary. However, it currently is.

When I download a file and it is put in ~/Desktop/Downloads, if I click on it again it is downloaded again as file(1).ext, and then as file(2).ext, etc. This is extremely annoying.
Comment 1 Reinout van Schouwen 2006-01-12 11:12:50 UTC
How should Epiphany know that the file being downloaded is the same file as the one on disk that accidentally has the same filename? The average webserver doesn't send an MD5 hash first does it?

However, I could support a Skip/Overwrite dialog when the auto download&open preference is disabled.

Setting severity:enhancement.
Comment 2 Cosimo Cecchi 2007-09-04 15:10:52 UTC
Created attachment 94937 [details] [review]
first attempt for a fix

The attached patch is a first attempt to have the dialog proposed by Reinout.
I think that the patch needs some more work though...for example, I did not find a way to get the parentWindow from inside MozDownload.cpp (is it just me or Mozilla code is way harder to hack than Gnome one?), so the dialog has the parent set to NULL.
Comments and suggestions are really welcomed!
Comment 3 Reinout van Schouwen 2007-09-04 16:06:17 UTC
@Cosimo, I haven't checked your patch yet (could you attach a screenshot?) but I'd like to point out that you might want to look at bug 341666 and its patch first.
Comment 4 Cosimo Cecchi 2007-09-04 16:32:45 UTC
Reinout: here is a screenshot
http://anarki.lilik.it/media/my/ephy_dialog.png
(Salva come = Save As)
I think the logic behind the two patches is slightly different, and both could be viable ways. The dialog in the screenshot will always pop-up when you use the "Download" function (obviously not when you use Save as...) and epiphany will find that a file with that name exists in your downloads directory, both if you use the auto open function and if you don't.
Comment 5 Reinout van Schouwen 2007-09-04 19:09:33 UTC
Cosimo: the point of the auto download & open feature is that it's a way of saying "Don't bother me with uninteresting questions, just show me the file!". Popping up this dialog when a file under the same name already exists, defeats that purpose. The one case where your dialog *would* be useful is when auto download is enabled and Epiphany doesn't recognize the MIME type. There's simply no use in popping up the download folder and having the user manually trash the duplicate, compared to showing this dialog.

Now, maybe Epiphany could somehow keep track of files it downloaded recently (via the Recent files stuff - Diego??) and minimize the possibility of duplicate downloading that way. Not just the filename but the URL where it came from should be stored. Maybe the Imran's history backend could help with that. But I digress.

Actually I was hoping that Josselin's patch and yours could be merged into one- do you think that's feasible?
Comment 6 Christian Persch 2007-09-04 19:39:54 UTC
Your editor seems to mix tabs and spaces for indentation... :)

+	BuildDownloadPath (filename, getter_AddRefs (destFile), &show_dialog);
+	if (show_dialog)
+	{
+		ShowSaveDialog (key, filename);
+	}
+	else 
+	{
+		g_free (filename);
+	}
+	
+	return NS_OK;

That should return the rv of BuildDownloadPath, not always NS_OK.

+nsresult StartDownload (char *path, nsILocalFile **_retval)
 {
-        int i;
-        static const char * const compression[] = {".gz", ".bz2", ".Z", ".lz", NULL};
-
-        for (i = 0; compression[i] != NULL; i++)
-        {
-                if (g_str_has_suffix (filename, compression[i]))
-                        return compression[i];
-        }
+    nsCOMPtr <nsILocalFile> destFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
+   	NS_ENSURE_TRUE (destFile, NS_ERROR_FAILURE);
 
-        return NULL;
+   	destFile->InitWithNativePath (nsCString (path));
+    g_free (path);

It's a bit unusual for a function to consume its input (freeing |path| here)...

+        dialog = gtk_message_dialog_new
+            (NULL,

We really should have a parent for this dialogue, if possible...

In case we have shown a filepicker already, we should have done this checking while the filepicker was up, not afterwards (the confirm-overwrite thingy on gtkfilechooser).

+        response = gtk_dialog_run (GTK_DIALOG (dialog));

If we really really need to run this dialogue, you need to protect this with a AutoJSContextStack instance (and if we have a parent DOM window, with a AutoWindowModalState instance). See other code in embed/mozilla/ using gtk_dialog_run on how to use them.
Comment 7 Christian Persch 2009-04-10 18:22:48 UTC
Reality check.
Comment 8 GNOME Infrastructure Team 2018-08-03 19:15:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/epiphany/issues/106.