erickutcher / httpdownloader

HTTP(S) download manager that uses input/output completion ports (IOCP).
https://erickutcher.github.io/#HTTP_Downloader
571 stars 62 forks source link

Automatically open files downloaded to the user's temp directory #193

Open redactedscribe opened 2 years ago

redactedscribe commented 2 years ago

When downloading a file in Firefox, it's possible to select "Open with" (instead of "Save File") which will download the file to the system's temporary directory and immediately open the file. With HTTP Downloader installed, the file downloads but no longer opens automatically.

I don't know if there is a way to detect whether the user chose "Open with" instead of "Save File", so an option to partially replicate this behaviour may have to naively rely on checking the download directory HTTP Downloader is using for a given file, i.e. "%username%\AppData\Local\Temp". This doesn't however account for if the user selected a different "Open with" program from the Firefox drop-down list, so the downloaded file would open with the associated default program regardless.

To keep things simpler (and probably more useful to users or all browsers), a suggested option would have to be "Automatically open files downloaded to the user's temp directory", rather than anything Firefox specific. I'd make use of this option as it's common for me to simply want to view/hear the downloaded file immediately (with the associated default program) and know that it's in the temp directory to be automatically deleted in time.

erickutcher commented 2 years ago

The extension API doesn't appear to show anything indicating that it's to be opened after downloading. It does show that it's being saved in the Temp folder, but that can be changed system wide and I'd be wary of executing anything unless I know for sure it's what the user wants.

I've always had a problem with the "Open with" option because it clutters up the Temp folder. Most people don't even know how to clear it either. The default Downloads folder has the same issue. I clean up people's computers from time to time and their Downloads folder is littered with installers and other junk. It feels gross.

Here's the real problem with having it automatically open files. It's entirely possible to have, for example, 100+ items finish downloading at the same time and all of them being opened at once. It's also possible to inadvertently run an executable and that's a huge security issue.

redactedscribe commented 2 years ago

The extension API doesn't appear to show anything indicating that it's to be opened after downloading.

I can only say that Firefox automatically running a file when using "Open with" has been a thing for as long as I can remember.

It does show that it's being saved in the Temp folder, but that can be changed system wide ...

It can be changed, but that shouldn't be a problem for HTTP Downloader with the currently used temporary directory defined by $env:TEMP/%temp%.

... I'd be wary of executing anything unless I know for sure it's what the user wants.

"Automatically open files downloaded to the user's temporary directory" would be an self-explanatory option, and therefore should be obvious as to what it does if enabled by a user. The feature could have a filter with file extensions defined that are considered safe, e.g. jpg; txt, and if the user wanted, ; exe and others could be appended. Due to the explicit steps needed to be taken to reach this point, it's fair to assume this is what the user would want.

I've always had a problem with the "Open with" option because it clutters up the Temp folder. Most people don't even know how to clear it either. The default Downloads folder has the same issue.

It's true, but I don't think those are typically the people who'd be aware of, or using, an external downloader. Those having sought out a program like HTTP Downloader will have at least some technical ability, and I imagine possess the know-how to clean their downloads/temporary directory should it become a problem. As of Windows 11, "temporary system and app files" are periodically cleaned up by default as far as I can tell (unlike in 10).

It's entirely possible to have, for example, 100+ items finish downloading at the same time ...

It would be in the user's control as they'd be the one choosing "Open with" over "Save file" per file (assuming Firefox), which is slow process. A hypothetical 100+ items finishing at once could only happen if added via HTTP Downloader (Add URL(s) window, or maybe drag and drop), and if all the downloads are set to download to the user's temporary directory.

It's also possible to inadvertently run an executable and that's a huge security issue.

How inadvertent is questionable as the user would have had to:

There's usually some user confirmation needed before an executable runs on contemporary Windows systems. With a filter as mentioned above, only safe files would be opened by default, posing little to no threat.