summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/ExtractArchive.py
diff options
context:
space:
mode:
authorGravatar Jochen Oberreiter <joberreiter@users.noreply.github.com> 2015-09-26 18:24:29 +0200
committerGravatar Jochen Oberreiter <joberreiter@users.noreply.github.com> 2015-09-26 18:24:29 +0200
commit93a0c1d930520c055eae766b5dad305111a02c4d (patch)
tree8ac3f9e6dcf682775f5b170f2a9ca40eb7c0f8fc /module/plugins/hooks/ExtractArchive.py
parentSpare plugin updates (diff)
parentMerge pull request #1850 from chaosblog/patch-2 (diff)
downloadpyload-93a0c1d930520c055eae766b5dad305111a02c4d.tar.xz
Merge pull request #1 from pyload/stable
Merge actual version
Diffstat (limited to 'module/plugins/hooks/ExtractArchive.py')
-rw-r--r--module/plugins/hooks/ExtractArchive.py53
1 files changed, 25 insertions, 28 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index eab196160..7d3d9237e 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
@@ -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 []
@@ -107,7 +108,7 @@ class ArchiveQueue(object):
class ExtractArchive(Addon):
__name__ = "ExtractArchive"
__type__ = "hook"
- __version__ = "1.49"
+ __version__ = "1.51"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , True ),
@@ -115,7 +116,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 ),
@@ -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
@@ -348,7 +348,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:
@@ -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
@@ -403,18 +403,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 +417,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 +430,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 +464,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'):
@@ -476,7 +473,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: