From 4cd2b7390dd97dc2016ab71f954f191de12f2f46 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Thu, 3 Sep 2015 20:37:17 +0200
Subject: Spare fixes (2)

---
 module/plugins/hooks/ExtractArchive.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'module/plugins/hooks/ExtractArchive.py')

diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index eab196160..87cd38ade 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -51,7 +51,7 @@ except ImportError:
     pass
 
 from module.plugins.internal.Addon import Addon, Expose, threaded
-from module.plugins.internal.Plugin import replace_patterns
+from module.plugins.internal.Plugin import exists, replace_patterns
 from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError
 from module.utils import fs_encode, save_join as fs_join, uniqify
 
@@ -107,7 +107,7 @@ class ArchiveQueue(object):
 class ExtractArchive(Addon):
     __name__    = "ExtractArchive"
     __type__    = "hook"
-    __version__ = "1.49"
+    __version__ = "1.50"
     __status__  = "testing"
 
     __config__ = [("activated"      , "bool"              , "Activated"                                 , True                                                                     ),
@@ -288,7 +288,7 @@ class ExtractArchive(Addon):
             if subfolder:
                 out = fs_join(out, pypack.folder)
 
-            if not os.path.exists(out):
+            if not exists(out):
                 os.makedirs(out)
 
             matched   = False
@@ -313,7 +313,7 @@ class ExtractArchive(Addon):
                     for fname, fid, fout in targets:
                         name = os.path.basename(fname)
 
-                        if not os.path.exists(fname):
+                        if not exists(fname):
                             self.log_debug(name, "File not found")
                             continue
 
@@ -356,7 +356,7 @@ class ExtractArchive(Addon):
 
                         for filename in new_files:
                             file = fs_encode(fs_join(os.path.dirname(archive.filename), filename))
-                            if not os.path.exists(file):
+                            if not exists(file):
                                 self.log_debug("New file %s does not exists" % filename)
                                 continue
 
@@ -476,7 +476,7 @@ class ExtractArchive(Addon):
                 deltotrash = self.get_config('deltotrash')
                 for f in delfiles:
                     file = fs_encode(f)
-                    if not os.path.exists(file):
+                    if not exists(file):
                         continue
 
                     if not deltotrash:
-- 
cgit v1.2.3


From 59d2ad3541bf133ddd69fd3b7c633e7e226e4829 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Mon, 21 Sep 2015 01:08:35 +0200
Subject: Spare improvements and fixes

---
 module/plugins/hooks/ExtractArchive.py | 42 +++++++++++++++-------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

(limited to 'module/plugins/hooks/ExtractArchive.py')

diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 87cd38ade..469f73141 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -107,7 +107,7 @@ class ArchiveQueue(object):
 class ExtractArchive(Addon):
     __name__    = "ExtractArchive"
     __type__    = "hook"
-    __version__ = "1.50"
+    __version__ = "1.51"
     __status__  = "testing"
 
     __config__ = [("activated"      , "bool"              , "Activated"                                 , True                                                                     ),
@@ -115,7 +115,6 @@ class ExtractArchive(Addon):
                   ("overwrite"      , "bool"              , "Overwrite files"                           , False                                                                    ),
                   ("keepbroken"     , "bool"              , "Try to extract broken archives"            , False                                                                    ),
                   ("repair"         , "bool"              , "Repair broken archives (RAR required)"     , False                                                                    ),
-                  ("test"           , "bool"              , "Test archive before extracting"            , False                                                                    ),
                   ("usepasswordfile", "bool"              , "Use password file"                         , True                                                                     ),
                   ("passwordfile"   , "file"              , "Password file"                             , "passwords.txt"                                                          ),
                   ("delete"         , "bool"              , "Delete archive after extraction"           , True                                                                     ),
@@ -348,7 +347,7 @@ class ExtractArchive(Addon):
 
                         #: Remove processed file and related multiparts from list
                         files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \
-                                    if fname not in archive.get_delete_files()]
+                                    if fname not in archive.items()]
                         self.log_debug("Extracted files: %s" % new_files)
 
                         for file in new_files:
@@ -403,18 +402,10 @@ class ExtractArchive(Addon):
             passwords = uniqify([password] + self.get_passwords(False)) if self.get_config('usepasswordfile') else [password]
             for pw in passwords:
                 try:
-                    if self.get_config('test') or self.repair:
-                        pyfile.setCustomStatus(_("archive testing"))
-                        if pw:
-                            self.log_debug("Testing with password: %s" % pw)
-                        pyfile.setProgress(0)
-                        archive.verify(pw)
-                        pyfile.setProgress(100)
-                    else:
-                        archive.check(pw)
-
-                    self.add_password(pw)
-                    break
+                    pyfile.setCustomStatus(_("archive testing"))
+                    pyfile.setProgress(0)
+                    archive.verify(pw)
+                    pyfile.setProgress(100)
 
                 except PasswordError:
                     if not encrypted:
@@ -425,9 +416,11 @@ class ExtractArchive(Addon):
                     self.log_debug(name, e)
                     self.log_info(name, _("CRC Error"))
 
-                    if self.repair:
-                        self.log_warning(name, _("Repairing..."))
+                    if not self.repair:
+                        raise CRCError("Archive damaged")
 
+                    else:
+                        self.log_warning(name, _("Repairing..."))
                         pyfile.setCustomStatus(_("archive repairing"))
                         pyfile.setProgress(0)
                         repaired = archive.repair()
@@ -436,15 +429,18 @@ class ExtractArchive(Addon):
                         if not repaired and not self.get_config('keepbroken'):
                             raise CRCError("Archive damaged")
 
-                        self.add_password(pw)
-                        break
-
-                    raise CRCError("Archive damaged")
+                        else:
+                            self.add_password(pw)
+                            break
 
                 except ArchiveError, e:
                     raise ArchiveError(e)
 
-            pyfile.setCustomStatus(_("extracting"))
+                else:
+                    self.add_password(pw)
+                    break
+
+            pyfile.setCustomStatus(_("archive extracting"))
             pyfile.setProgress(0)
 
             if not encrypted or not self.get_config('usepasswordfile'):
@@ -467,7 +463,7 @@ class ExtractArchive(Addon):
             pyfile.setProgress(100)
             pyfile.setStatus("processing")
 
-            delfiles = archive.get_delete_files()
+            delfiles = archive.items()
             self.log_debug("Would delete: " + ", ".join(delfiles))
 
             if self.get_config('delete'):
-- 
cgit v1.2.3


From f9fc367427e30b7a3ca2ccad6144cb76b21f0257 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@users.noreply.github.com>
Date: Mon, 21 Sep 2015 14:36:22 +0200
Subject: Spare code cosmetics

---
 module/plugins/hooks/ExtractArchive.py | 1 +
 1 file changed, 1 insertion(+)

(limited to 'module/plugins/hooks/ExtractArchive.py')

diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index 469f73141..7d3d9237e 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -66,6 +66,7 @@ class ArchiveQueue(object):
     def get(self):
         try:
             return [int(pid) for pid in self.plugin.retrieve("ExtractArchive:%s" % self.storage, "").decode('base64').split()]
+
         except Exception:
             return []
 
-- 
cgit v1.2.3