Firefox temporary files

To delete the temporary file as soon as possible, you can write a wrapper, like:

#!/bin/sh
the-application "$1"
rm -f "$1"

replacing the-application by the name of the real executable, and ask Firefox to use this wrapper instead of the application. Or:

#!/bin/sh
the-application "$1"
case "$1" in
  /tmp/*) rm -f "$1" ;;
esac

This form is safer in case future Firefox versions do not create a new file for "file:" URL's (you don't want the file to be removed in this case).

Note that some applications return immediately and may fail to work correctly if the file is removed before the application is quit. In such a case, there isn't much you can do (at least in a reliable way).

Concerning the alternative (to replace an existing file with the same name), this can yield clashes with other applications that use /tmp, with possible security implications. This is not a good idea in general.

Tags:

Firefox

Tmp