summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/AntiVirus.py14
-rw-r--r--module/plugins/hooks/ExtractArchive.py24
2 files changed, 28 insertions, 10 deletions
diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py
index ac9373a37..c620f556d 100644
--- a/module/plugins/hooks/AntiVirus.py
+++ b/module/plugins/hooks/AntiVirus.py
@@ -16,7 +16,7 @@ from module.utils import fs_encode, save_join
class AntiVirus(Hook):
__name__ = "AntiVirus"
__type__ = "hook"
- __version__ = "0.08"
+ __version__ = "0.09"
#@TODO: add trash option (use Send2Trash lib)
__config__ = [("action" , "Antivirus default;Delete;Quarantine", "Manage infected files" , "Antivirus default"),
@@ -80,11 +80,19 @@ class AntiVirus(Hook):
try:
send2trash.send2trash(file)
- except Exception:
- self.logWarning(_("Unable to move file to trash, move to quarantine instead"))
+ except NameError:
+ self.logWarning(_("Send2Trash lib not found, moving to quarantine instead"))
pyfile.setCustomStatus(_("file moving"))
shutil.move(file, self.getConfig('quardir'))
+ except Exception, e:
+ self.logWarning(_("Unable to move file to trash: %s, moving to quarantine instead") % e.message)
+ pyfile.setCustomStatus(_("file moving"))
+ shutil.move(file, self.getConfig('quardir'))
+
+ else:
+ self.logDebug(_("Successfully moved file to trash"))
+
elif action == "Quarantine":
pyfile.setCustomStatus(_("file moving"))
shutil.move(file, self.getConfig('quardir'))
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 05a1e368a..07a2ba228 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -110,7 +110,7 @@ class ArchiveQueue(object):
class ExtractArchive(Hook):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.42"
+ __version__ = "1.43"
__config__ = [("activated" , "bool" , "Activated" , True ),
("fullpath" , "bool" , "Extract with full paths" , True ),
@@ -187,6 +187,11 @@ class ExtractArchive(Hook):
@threaded
def extractQueued(self, thread):
+ if self.extracting: #@NOTE: doing the check here for safty (called by coreReady)
+ return
+
+ self.extracting = True
+
packages = self.queue.get()
while packages:
if self.lastPackage: #: called from allDownloadsProcessed
@@ -200,6 +205,8 @@ class ExtractArchive(Hook):
packages = self.queue.get() #: check for packages added during extraction
+ self.extracting = False
+
@Expose
def extractPackage(self, *ids):
@@ -222,7 +229,7 @@ class ExtractArchive(Hook):
def allDownloadsProcessed(self):
self.lastPackage = True
- if not self.extracting:
+ if self.getConfig('waitall') and not self.extracting:
self.extractQueued()
@@ -231,8 +238,6 @@ class ExtractArchive(Hook):
if not ids:
return False
- self.extracting = True
-
processed = []
extracted = []
failed = []
@@ -374,7 +379,6 @@ class ExtractArchive(Hook):
self.queue.remove(pid)
- self.extracting = False
return True if not failed else False
@@ -472,8 +476,14 @@ class ExtractArchive(Hook):
try:
send2trash.send2trash(file)
- except Exception:
- self.logWarning(_("Unable to move %s to trash") % os.path.basename(f))
+ except NameError:
+ self.logWarning(_("Unable to move %s to trash: Send2Trash lib not found") % os.path.basename(f))
+
+ except Exception, e:
+ self.logWarning(_("Unable to move %s to trash: %s") % (os.path.basename(f), e.message))
+
+ else:
+ self.logDebug(_("Successfully moved %s to trash") % os.path.basename(f))
self.logInfo(name, _("Extracting finished"))
extracted_files = archive.files or archive.list()