bower
bower copied to clipboard
Temporary file gets deleted too soon?
I often find myself opening certain HTML emails in the browser, with "xdg-open&". I noticed that there is some delay (around a second) before the browser tab actually gets opened. (Only for these emails, for some reason) When this happens, bower has usually already deleted the temporary file by the time xdg-open has identified the file and forwarded it to the browser.
Obviously, the real bug here is that "xdg-open" takes too long on these files, for unknown reasons. But I think it's still bad UX from the side of bower for me to have to wait for the attachment to finish opening at all, before I can press away the message.
I think it would be better for bower to keep them around, either for a set amount of time, or until program exit. (I don't usually keep my mail client open when I'm not expecting mail, personally)
It seems to be reproducible with practically any HTML file:
$ echo '<html><body>Example</body></html>' > example
$ time xdg-open example
xdg-open example 0.48s user 0.13s system 102% cpu 0.599 total
$ time firefox example
firefox example 0.05s user 0.02s system 73% cpu 0.101 total
So it definitely is an xdg-open
bug as well.
Another possible solution:
Add the possibility of detecting HTML MIME types (text/html
) and opening them with the open_url
command instead of the open_part
command by default. Then I can just point open_url
at firefox&
and circumvent xdg-open
.
A simple solution is to defer deleting all temporary files until we leave the thread view. I've mocked it up on the defer-rm-temp
branch.
A question is when opening a part with a foreground command, i.e. without a trailing &
, should the temporary file be deleted as soon as the command returns. That assumes the command only returns once the user is done viewing the part, which I guess would not be true if you use xdg-open
to launch a web browser. On the other hand, email parts are small and keeping them around for a little longer doesn't really hurt.