Frustration with Firefox snap downloads

There are many posts about this on other fora, but I don’t find any here and suspect that this is the more appropriate venue. I have tried various settings for download directory in Firefox snap and find most of them non-functional. For a while I had success with choosing “/var/tmp” in the browser, which resulted in an actual directory of /var/run/user//doc, but my last attempt resulted instead in a new directory like systemd-private-636276c188464b78933aafcf914c50e2-upower.service-VezNYb being created directly under /var/tmp for each download. These directories are created with no privileges and “root” as both group and owner and are consequently inaccessible. Like other configurations I have tried, the end result is that Firefox is unable to download anything or, if it does, whatever it downloaded cannot be accessed. Is there a reliable, sensible solution for this? Many posts recommend abandoning snap and installing the .deb version of Firefox, but I am reluctant to do this, as I naively assume that Canonical had good reasons for switching from the native installation ot the snap version.

Is there some reason you can’t just point it to /home/$USER/Downloads?

I have that set in the Firefox snap and it works fine here.

Thanks for responding. This is a popular solution, but I forgot to mention that I wanted the temporary downloads to really be temporary. With your solution I will need to write a startup script to clean out temporary downloads. I have given in and gone back to opening PDFs directly in Firefox, which paradoxically still allows me to then store the files anywhere in the local file system, despite “sandboxing”. Of course, I now have no idea where Firefox snap is putting the files it opens in its own PDF viewer or how I can make sure they don’t accumulate in that location.

1 Like

Ah! I have indeed got a cron job on my laptop which does exactly what you’re talking about.

@daily find ~/Downloads/* -mtime +14 -delete

:smiley:

Actually, my Firefox settings do direct downloads to `/home/$USER/Downloads. However, what I see is numerous numbered directories dated 1970-01-01 under /var/run/user//doc/ and directories with the same name under /var/run/user//by-app/snap.firefox/. Firefox seems to be storing copies of downloads at both of these locations.

Not Firefox itself but the XDG portals do use this place as a backend storage, it is an implementation detail and should not be accessed directly be the user, the portals will transparently show the actual download location in the UI to you …

Thanks for the explanation, but there are several problems with this:

  1. When I click on the folder symbol next to a downloaded file, nothing happens.
  2. Firefox doesn’t clean up after itself: Under /var/run/user/<userid>/doc/ I have 480 directories. Most of them are empty, but a few of them still contain files. The same applies to /var/run/user/<userid>/by-app/snap.firefox/ which contains 485 directories.
  3. The fact that the directories don’t have usable timestamps complicates any cleanup attempt.

What is the recommended “best practice” for preventing the accumulation of temporary files or download directories when using Firefox snap?

P.S. As you can see, I finally figured out that I had to use “code” formatting to prevent the forum software from eliding "<userid>".

This is not Firefox’s job at all, it cant even see these dirs AFAIK, only the portal internals can.

The dir is a tmpfs which will be cleaned on reboot, if you care about 4kb per empty dir being used of your ram you should perhaps file a bug against xdg-portals but i think this is the desired behavior …

Thanks again. In that case, I would prefer the approach that @popey describes. How can I achieve that?

1 Like

Just replace ~/Downloads/* in the cron job with the dir you want to be cleaned up …

1 Like

As a test, I tried the following command:

find doc/* -mtime +14 -delete

The result was numerous errors like: `

Operation not permitted

` or

No such file or directory

and what made you pick this dir ? this isnt one of the dirs you were talking about above, use the full path …

Yes it is: I ran the command from

/var/run/user/<userid>

because I was planning to do the same for

./ by-app/snap.firefox/

P.S. Rerunning the command with the full path resulted in the same error messages.

find /var/run/user/1993401104/doc/by-app/snap.firefox/* -mtime +14 -delete

delivers similar messages.