Closed tigoesnumb3rs closed 7 years ago
Hi, you can use the approach described here to prevent the files from being deleted before they are closed:
https://github.com/astroidmail/astroid/wiki/Opening-attachments-and-virus-detection
Regards, Gaute
Thanks, the link put me in the right direction. I can now open attachments using the following script:
#!/bin/bash
cachedir=~/.cache/astroid-attachments
attachment=$(echo $1 | sed "s#.*astroid/##")
touch $cachedir/token.$attachment
mv $1 ~/.cache/astroid-attachments/
inotifywait -e close "$1" &
ip=$!
# open file (you can replace this with xdg-open)
xdg-open "$cachedir/$attachment"
while inotifywait -r -e close $cachedir/$attachment; do rm $cachedir/token.$attachment || rm $cachedir/$attachment; done
The script moves the file to ~/.cache/astroid-attachements
before astroid can delete it and creates a second empty file inside the same directory.
Then the file is opened using xdg-open and the inotifywait loop is started to wait for the file to be closed. At this point, since the inotifywait loop raises an close event immediately after starting, the token
-file is removed. When the file is closed in the application the token-file is removed a second time, which fails and triggers the removal of the actual attachment file.
Probably not the best solution, but it works.
Great, I think it might be worth putting in a sleep
somewhere as well. Then it should work with out the move.
Hey,
I've astroid 0.9.1 set up using:
However I can't seem to open attachments properly. The correct applications are opened, and astroid copies the attachment into
~/.cache/astroid/
, however the files are deleted immediately after they are created.This is the log output:
I don't think this is the intended behavoir, and would be happy if this could be fixed or if anyone could tell me how to properly configure astroid. I don't think the
cheers