diff options
author | Olivier <olivier-dev@gmx.com> | 2016-06-08 08:26:04 +0200 |
---|---|---|
committer | Olivier <olivier-dev@gmx.com> | 2016-06-08 08:26:04 +0200 |
commit | 411d8031c3ce4547b9f165761f74f0067bea7e7b (patch) | |
tree | 2216cb784cfcf48f298da062bf6427bfa8e76eab /module | |
parent | [FilerNet] Fix #2489 (diff) | |
download | pyload-411d8031c3ce4547b9f165761f74f0067bea7e7b.tar.xz |
[ExtractArchive] Fix
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 23 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 13 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 5 | ||||
-rw-r--r-- | module/plugins/internal/UnTar.py | 5 |
4 files changed, 26 insertions, 20 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 6d559bfcb..b9e6842cf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -277,15 +277,15 @@ class ExtractArchive(Addon): matched = False success = True - files_ids = dict((fdata['name'], ((fsjoin(dl_folder, pypack.folder, fdata['name'])), fid, out)) for fid, fdata \ - in sorted(pypack.getChildren().values(), key=lambda k: k['name'])).items() #: Remove duplicates + files_ids = dict((fdata['name'], (fdata['id'], (fsjoin(dl_folder, pypack.folder, fdata['name'])), out)) for fdata \ + in pypack.getChildren().values()).values() #: Remove duplicates #: Check as long there are unseen files while files_ids: new_files_ids = [] if extensions: - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ + files_ids = [(fid, fname, fout) for fid, fname, fout in files_ids \ if filter(lambda ext: fname.lower().endswith(ext), extensions)] for Extractor in self.extractors: @@ -294,7 +294,7 @@ class ExtractArchive(Addon): self.log_debug("Targets for %s: %s" % (Extractor.__name__, targets)) matched = True - for fname, fid, fout in targets: + for fid, fname, fout in targets: name = os.path.basename(fname) if not exists(fname): @@ -304,15 +304,14 @@ class ExtractArchive(Addon): self.log_info(name, _("Extract to: %s") % fout) try: pyfile = self.pyload.files.getFile(fid) - archive = Extractor(self, + archive = Extractor(pyfile, fname, fout, fullpath, overwrite, excludefiles, priority, - keepbroken, - fid) + keepbroken) thread.addActive(pyfile) archive.init() @@ -330,12 +329,12 @@ class ExtractArchive(Addon): continue #: Remove processed file and related multiparts from list - files_ids = [(fname, fid, fout) for fname, fid, fout in files_ids \ + files_ids = [(fid, fname, fout) for fid, fname, fout in files_ids \ if fname not in archive.items()] self.log_debug("Extracted files: %s" % new_files) - for file in new_files: - self.set_permissions(file) + for filename in new_files: + self.set_permissions(filename) for filename in new_files: file = encode(fsjoin(os.path.dirname(archive.filename), filename)) @@ -344,7 +343,7 @@ class ExtractArchive(Addon): continue if recursive and os.path.isfile(file): - new_files_ids.append((filename, fid, os.path.dirname(filename))) #: Append as new target + new_files_ids.append((fid, filename, os.path.dirname(filename))) #: Append as new target self.manager.dispatchEvent("archive_extracted", pyfile, archive) @@ -447,7 +446,7 @@ class ExtractArchive(Addon): pyfile.setProgress(100) pyfile.setStatus("processing") - delfiles = archive.items() + delfiles = archive.chunks() self.log_debug("Would delete: " + ", ".join(delfiles)) if self.config.get('delete'): diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 8a16cdd38..3c9af376a 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -104,7 +104,7 @@ class Extractor(Plugin): self.excludefiles = excludefiles self.priority = priority self.keepbroken = keepbroken - self.progress = lambda x: pyfile.setProgress(int(x)) + self.files = None self.init() @@ -119,11 +119,6 @@ class Extractor(Plugin): return encode(self.out) - def _log(self, level, plugintype, pluginname, messages): - messages = (self.__name__,) + messages - return self.pyfile.plugin._log(level, plugintype, self.pyfile.plugin.__name__, messages) - - def verify(self, password=None): """ Testing with Extractors built-in method @@ -156,3 +151,9 @@ class Extractor(Plugin): Return list of archive files """ raise NotImplementedError + + def progress(self, x): + """ + Set extraction progress + """ + return self.pyfile.setProgress(int(x)) diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 3b1d7b290..b91f2455b 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -123,7 +123,7 @@ class UnRar(Extractor): break #: Reading a percentage sign -> set progress and restart if c == "%": - self.notifyprogress(int(s)) + self.pyfile.setProgress(int(s)) s = "" #: Not reading a digit -> therefore restart elif c not in string.digits: @@ -155,6 +155,9 @@ class UnRar(Extractor): if p.returncode: raise ArchiveError(_("Process return code: %d") % p.returncode) + self.files = self.list(password) + return self.files + def chunks(self): dir, name = os.path.split(self.filename) diff --git a/module/plugins/internal/UnTar.py b/module/plugins/internal/UnTar.py index f2a140ca7..7cc8516ae 100644 --- a/module/plugins/internal/UnTar.py +++ b/module/plugins/internal/UnTar.py @@ -25,7 +25,10 @@ class UnTar(Extractor): @classmethod def isarchive(cls, filename): - return tarfile.is_tarfile(encode(filename)) + try: + return tarfile.is_tarfile(encode(filename)) + except: + return False @classmethod |