Sun, 20 Jul 2008 20:25:54 -0400
Clean the target directory if an extraction attempt failed.
TODO | file | annotate | diff | comparison | revisions | |
scripts/dtrx | file | annotate | diff | comparison | revisions |
--- a/TODO Tue Jul 15 22:18:03 2008 -0400 +++ b/TODO Sun Jul 20 20:25:54 2008 -0400 @@ -2,8 +2,12 @@ To do: -* Everything is messed up when an archive contains one file... but I forget - what I meant by this. +* Add a test for the case where you x -l a misnamed file. + +* If any of the extraction processes succeeds, only show stderr for that + one. + +* Investigate the right way to handle SIGPIPE and do so. * When we extract a compressed file (or just one file?), check to see if it itself is an archive. Follow all the usual rules for recursive
--- a/scripts/dtrx Tue Jul 15 22:18:03 2008 -0400 +++ b/scripts/dtrx Sun Jul 20 20:25:54 2008 -0400 @@ -989,6 +989,13 @@ self.successes = [] self.failures = [] + def clean_destination(self, dest_name): + try: + os.unlink(dest_name) + except OSError, error: + if error.errno == errno.EISDIR: + shutil.rmtree(dest_name, ignore_errors=True) + def abort(self, signal_num, frame): signal.signal(signal_num, signal.SIG_IGN) print @@ -1001,11 +1008,7 @@ for directory in clean_targets: os.chdir(directory) for path in glob.glob('.dtrx-*'): - try: - os.unlink(path) - except OSError, error: - if error.errno == errno.EISDIR: - shutil.rmtree(path, ignore_errors=True) + self.clean_destination(path) sys.exit(1) def parse_options(self, arguments): @@ -1088,6 +1091,8 @@ error = self.action.run(filename, extractor) if error: errors.append((extractor.file_type, extractor.encoding, error)) + if extractor.target is not None: + self.clean_destination(extractor.target) else: self.recurse(filename, extractor, self.action) return