[svn] Be a little nicer about explaining that we can't extract to the current trunk

Fri, 23 Nov 2007 17:55:07 -0500

author
brett
date
Fri, 23 Nov 2007 17:55:07 -0500
branch
trunk
changeset 40
ee6a869f8da1
parent 39
027fcd7ae002
child 41
e3675644bbb6

[svn] Be a little nicer about explaining that we can't extract to the current
directory.

TODO file | annotate | diff | comparison | revisions
scripts/dtrx file | annotate | diff | comparison | revisions
tests/tests.yml file | annotate | diff | comparison | revisions
--- a/TODO	Fri Nov 23 16:25:22 2007 -0500
+++ b/TODO	Fri Nov 23 17:55:07 2007 -0500
@@ -1,11 +1,7 @@
-* Make sure you only try each extractor once?
-
 Things which I have a use case/anti-use case for:
 * Support pisi packages (http://paketler.pardus.org.tr/pardus-2007/)
 * Steal ideas from <http://martin.ankerl.com/files/e>.
-* Figure out what the deal is with strerror. (done?)
-* Better error messages (file doesn't exist, isn't readable, etc.)
-* Consistently raise and handle exceptions.
+* More consistently raise and handle exceptions.
 
 Things that are generally good:
 * Better tests.
--- a/scripts/dtrx	Fri Nov 23 16:25:22 2007 -0500
+++ b/scripts/dtrx	Fri Nov 23 17:55:07 2007 -0500
@@ -211,7 +211,10 @@
         return '.'.join(pieces)
 
     def extract(self):
-        self.target = tempfile.mkdtemp(prefix='.dtrx-', dir='.')
+        try:
+            self.target = tempfile.mkdtemp(prefix='.dtrx-', dir='.')
+        except (OSError, IOError), error:
+            raise ExtractorError("cannot extract here: %s" % (error.strerror,))
         old_path = os.path.realpath(os.curdir)
         os.chdir(self.target)
         try:
@@ -251,7 +254,10 @@
     def extract(self):
         self.content_type = ONE_ENTRY_KNOWN
         self.content_name = self.basename()
-        output_fd, self.target = tempfile.mkstemp(prefix='.dtrx-', dir='.')
+        try:
+            output_fd, self.target = tempfile.mkstemp(prefix='.dtrx-', dir='.')
+        except (OSError, IOError), error:
+            raise ExtractorError("cannot extract here: %s" % (error.strerror,))
         try:
             self.run_pipes(output_fd)
         except ExtractorError:
--- a/tests/tests.yml	Fri Nov 23 16:25:22 2007 -0500
+++ b/tests/tests.yml	Fri Nov 23 17:55:07 2007 -0500
@@ -447,7 +447,6 @@
   prerun: |
     touch unreadable-file.tar.gz
     chmod 000 unreadable-file.tar.gz
-  cleanup: rm -f unreadable-file.tar.gz
   error: true
   grep: "[Pp]ermission denied"
 
@@ -456,7 +455,6 @@
   prerun: |
     touch unreadable-file.zip
     chmod 000 unreadable-file.zip
-  cleanup: rm -f unreadable-file.zip
   error: true
   grep: "[Pp]ermission denied"
 
@@ -467,3 +465,10 @@
   cleanup: rm -f bogus-file.tar.gz
   error: true
   grep: "returned status code [^0]"
+
+- name: try to extract in unwritable directory
+  directory: unwritable-dir
+  filenames: ../test-1.23.tar.gz
+  prerun: chmod 500 .
+  error: true
+  grep: "cannot extract here: [Pp]ermission denied"

mercurial