summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/AntiVirus.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-01 02:54:22 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-01 02:54:22 +0200
commit711621f3d3a59f7ec5c2684dfac921e2c5902563 (patch)
treeb9a5f3923c43f5bf62f737a1775b15504ce0027b /module/plugins/hooks/AntiVirus.py
parent[XFSCrypter] Improve LINK_PATTERN (diff)
downloadpyload-711621f3d3a59f7ec5c2684dfac921e2c5902563.tar.xz
Fix https://github.com/pyload/pyload/issues/1351
Diffstat (limited to 'module/plugins/hooks/AntiVirus.py')
-rw-r--r--module/plugins/hooks/AntiVirus.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index 27e3801b5..ac9373a37 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -4,6 +4,11 @@ import os
import shutil
import subprocess
+try:
+ import send2trash
+except ImportError:
+ pass
+
from module.plugins.Hook import Hook, Expose, threaded
from module.utils import fs_encode, save_join
@@ -11,7 +16,7 @@ from module.utils import fs_encode, save_join
class AntiVirus(Hook):
__name__ = "AntiVirus"
__type__ = "hook"
- __version__ = "0.07"
+ __version__ = "0.08"
#@TODO: add trash option (use Send2Trash lib)
__config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"),
@@ -33,16 +38,6 @@ class AntiVirus(Hook):
def setup(self):
self.info = {} #@TODO: Remove in 0.4.10
- try:
- import send2trash
-
- except ImportError:
- self.logDebug("Send2Trash lib not found")
- self.trashable = False
-
- else:
- self.trashable = True
-
@Expose
@threaded
@@ -81,13 +76,14 @@ class AntiVirus(Hook):
if not self.getConfig('deltotrash'):
os.remove(file)
- elif self.trashable:
- send2trash.send2trash(file)
-
else:
- self.logWarning(_("Unable to move file to trash, move to quarantine instead"))
- pyfile.setCustomStatus(_("file moving"))
- shutil.move(file, self.getConfig('quardir'))
+ try:
+ send2trash.send2trash(file)
+
+ except Exception:
+ self.logWarning(_("Unable to move file to trash, move to quarantine instead"))
+ pyfile.setCustomStatus(_("file moving"))
+ shutil.move(file, self.getConfig('quardir'))
elif action == "Quarantine":
pyfile.setCustomStatus(_("file moving"))