elinks
elinks copied to clipboard
Online images don't open on macOS
For some reason images on webpages don't open on macOS. This problem does not occur with local documents. I see a similar behavior with links too... Here's an example error from Preview (default in-built image viewing app on macOS):
This was tried on the google logo image on google's main page google.com
Is this viewer run by mailcap?
index 210df959..cd3c86ad 100644
--- a/src/session/download.c
+++ b/src/session/download.c
@@ -378,7 +378,7 @@ exec_mailcap_command(void *data)
add_to_string(&string, "mailcap:");
add_to_string(&string, exec_mailcap->command);
- if (exec_mailcap->file) {
+ if (0 && exec_mailcap->file) {
add_to_string(&string, " && /bin/rm -f ");
add_to_string(&string, exec_mailcap->file);
}
Does such change do any difference? elinks won't delete this temporary file.
@rkd77 Yes the viewer is run by mailcap. What is interesting is that the same viewer works for local html documents. On macOS I don't know of any other better technique. The snippet from my mailcap is posted below. All other programs, mutt, lynx etc work well with these mailcap entries, but links and elinks do not when image is on remote and downloaded on demand. Where does elinks download images? Shouldn't elinks pass a full path to the file? From the message it looks like the path is not full path for downloaded images.
Also, the change you suggest did not make any difference.
image/jpeg; open -a 'Preview' %s;
image/gif; open -a 'Preview' %s;
image/*; open -a 'Preview' %s;
@amanvm on the testing branch there are some logging statements. Could you compile and check some non local image: elinks 2> log What is value of environment variable TMPDIR ? And what is in log?
@rkd77:
% echo $TMPDIR
/var/folders/4v/hg2cqzyx3rd9hv7kx2_7b8w40000gn/T/
% cat log
path=/var/folders/4v/hg2cqzyx3rd9hv7kx2_7b8w40000gn/T//elinksSD6WF1.png
And the message from Preview for the same:
Added more debug. Gather logs again, please.
@amanvm please, check now and show log, File is not removed, at least not it in exec_thread.
@rkd77 This time Preview did show the image correctly! Image files are not being deleted from TMPDIR, so you might want to change that before merging in master branch. Here's the log, if it matters: log.txt
Please, try once again. This time fork "version" of exec_no_stdin will be run. I uncommented unlink, so this time the temporary file will be removed. If ok, we found solution. If not, no idea how to fix it yet.
@rkd77 Doesn't work now...
@amanvm what if add -W to mailcap:
open -W -a 'Preview' %s
@rkd77 Works, but with a new error that always happens.
Unable to block on applications (kqueue() failed: Result too large)
Note: open -W -a 'Preview' %s works even with master branch, but with same error as above. So adding -W makes the rest of the code appear unnecessary in testing branch.
I guess Preview is running in background, and open only pass filename to it and exits immediately.
When open exits, the temporary file is removed. If you propose algorithm how to deal with temporary files in such case, maybe I will implement it. Now, you can try something different. Some other application similar to Linux ones instead of open. For example under Linux there is display from Imagick. You can have separate mailcap file only for ELinks.
@rkd77 Well one thing that does not give error is open -nW -a 'Preview' %s. But it also does not delete the file... And that works with the master branch too, without needing any of the changes here.
I've got an idea. Add another config option "postpone unlink temporary files till exit". Remember all temporary files, and remove them at elinks's exit. What do you think?
To test set ui.sessions.postpone_unlink = 1 on master branch. I like the idea, it can be useful not only on MacOS.
@rkd77 Works well, thanks! Though you might also consider associating the image link with temporary image file downloaded. So elinks won't redownload the same image in the same session if user is closes the viewer and clicks on the link again. And maybe upon reloading the page, elinks clear the association of image links for that page so images would be redownloaded again on click.
There is no yet possibility to clear cache when reload, but there is progress. Images are cached when ui.sessions.postpone_unlink = 1. There is no check if file exists, but can be added later.