Recurse better when the contents were just one file. trunk

Thu, 10 Jul 2008 20:55:09 -0400

author
Brett Smith <brett@brettcsmith.org>
date
Thu, 10 Jul 2008 20:55:09 -0400
branch
trunk
changeset 71
b0290eeb3b7a
parent 70
48d2421a3178
child 72
c4cfaf634bb9
child 88
5df4dd9d046a

Recurse better when the contents were just one file.

scripts/dtrx file | annotate | diff | comparison | revisions
tests/test-one-archive.tar.gz file | annotate | diff | comparison | revisions
tests/tests.yml file | annotate | diff | comparison | revisions
--- a/scripts/dtrx	Thu Jul 10 20:09:12 2008 -0400
+++ b/scripts/dtrx	Thu Jul 10 20:55:09 2008 -0400
@@ -1025,9 +1025,17 @@
         self.options.recursion_policy.prep(filename, action.target, extractor)
         if self.options.recursion_policy.ok_to_recurse():
             for filename in extractor.included_archives:
+                logger.debug("recursing with %s archive" %
+                             (extractor.content_type,))
                 tail_path, basename = os.path.split(filename)
-                directory = os.path.join(self.current_directory, action.target,
-                                         extractor.included_root, tail_path)
+                path_args = [self.current_directory, extractor.included_root,
+                             tail_path]
+                logger.debug("included root: %s" % (extractor.included_root,))
+                logger.debug("tail path: %s" % (tail_path,))
+                if os.path.isdir(action.target):
+                    logger.debug("action target: %s" % (action.target,))
+                    path_args.insert(1, action.target)
+                directory = os.path.join(*path_args)
                 self.archives.setdefault(directory, []).append(basename)
 
     def check_file(self, filename):
Binary file tests/test-one-archive.tar.gz has changed
--- a/tests/tests.yml	Thu Jul 10 20:09:12 2008 -0400
+++ b/tests/tests.yml	Thu Jul 10 20:55:09 2008 -0400
@@ -593,3 +593,14 @@
   filenames: ../test-onefile.tar.gz
   baseline: tar -zxf $1
   antigrep: "contains"
+
+- name: test recursive extraction of one archive
+  directory: inside-dir
+  options: ""
+  filenames: ../test-one-archive.tar.gz
+  baseline: |
+    tar -zxf $1
+    zcat test-text.gz >test-text
+  input: |
+    h
+    o

mercurial