summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/UnRar.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-31 23:19:30 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-31 23:19:30 +0100
commit7368881d2ba95cca3f47afbb0f4ef5861f2774df (patch)
tree9e34209590c03e1bb5c5897840f7250b113d9192 /module/plugins/internal/UnRar.py
parentSpare code cosmetics (diff)
downloadpyload-7368881d2ba95cca3f47afbb0f4ef5861f2774df.tar.xz
Extractor final fixup
Diffstat (limited to 'module/plugins/internal/UnRar.py')
-rw-r--r--module/plugins/internal/UnRar.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index f92a2ddd4..fbb1c6a3e 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -71,7 +71,7 @@ class UnRar(Extractor):
if not cls.isArchive(fname):
continue
- m = cls.re_rarpart1.match(fname)
+ m = cls.re_rarpart1.search(fname)
if not m or int(m.group(1)) == 1: #@NOTE: only add first part file
targets.append((fname, id))
@@ -86,17 +86,13 @@ class UnRar(Extractor):
raise PasswordError
if self.re_wrongcrc.search(err):
- raise CRCError
+ raise CRCError(err)
# output only used to check if passworded files are present
for attr in self.re_filelist.findall(out):
if attr[0].startswith("*"):
raise PasswordError
- self.files = self.list()
- if not self.files:
- raise ArchiveError("Empty Archive")
-
def isPassword(self, password):
# at this point we can only verify header protected files
@@ -158,13 +154,13 @@ class UnRar(Extractor):
raise PasswordError
elif self.re_wrongcrc.search(err):
- raise CRCError
+ raise CRCError(err)
elif err.strip(): #: raise error if anything is on stderr
- raise ArchiveError(err.strip())
+ raise ArchiveError(err)
if p.returncode:
- raise ArchiveError("Process terminated")
+ raise ArchiveError(_("Process return code: %d") % p.returncode)
if not self.files:
self.files = self.list(password)
@@ -176,8 +172,11 @@ class UnRar(Extractor):
for i in (1, 2):
try:
dir, name = os.path.split(self.filename)
- part = self.getattr(self, "re_rarpart%d" % i).match(name).group(1)
- file = fs_encode(os.path.join(dir, name.replace(part, '*', 1)))
+
+ part = self.getattr(self, "re_rarpart%d" % i).search(name).group(1)
+ new_name = name[::-1].replace((".part%s.rar" % part)[::-1], ".part*.rar"[::-1], 1)[::-1]
+ file = fs_encode(os.path.join(dir, new_name)
+
files.extend(glob(file))
except Exception:
@@ -196,7 +195,7 @@ class UnRar(Extractor):
out, err = p.communicate()
if "Cannot open" in err:
- raise ArchiveError("Cannot open file")
+ raise ArchiveError(_("Cannot open file"))
if err.strip(): #: only log error at this point
self.manager.logError(err.strip())