chiark / gitweb /
backend.py: Use configured delimiter for joining fields.
[chopwood] / agpl.py
diff --git a/agpl.py b/agpl.py
index 41ee376..a35ea3f 100644 (file)
--- a/agpl.py
+++ b/agpl.py
@@ -142,13 +142,22 @@ def filez(cmd):
         if z < 0: break
         f = buf[i:z]
         i = z + 1
-        if f == '.': continue
+        if f.rstrip('/') == '.': continue
         if f.startswith('./'): f = f[2:]
         yield f
 
       ## Whatever's left over will be dealt with next time through.
       left = buf[i:]
 
+    ## Make sure the command actually completed successfully.
+    if kid.wait():
+      rc = kid.returncode
+      raise U.ExpectedError, \
+          (500, "lister command `%s' failed (%s) in `%s'" % (
+            cmd,
+            (rc & 0xff00) and 'rc = %d' % (rc >> 8) or 'signal %d' % rc,
+            dir))
+
     ## If there's trailing junk left over then we should complain.
     if left:
       raise U.ExpectedError, \
@@ -189,28 +198,27 @@ def dump_dir(name, dir, dirmap, tf, root):
 
     ## Work through each file.
     for file in lister(dir):
-      full = OS.path.join(dir, file)
-      tarname = OS.path.join(root, name, file)
-      skip = False
-
-      ## Check for symbolic links.  If we find one that points to another
-      ## directory we're going to dump separately then fiddle it so that it
-      ## works in the directory tree we're going to make.
-      if OS.path.islink(full):
-        dest = OS.path.realpath(full)
-        for d, local in dirmap:
-          if dest.startswith(d):
-            fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]),
-                                  OS.path.join('/', name,
-                                               OS.path.dirname(file)))
-            st = OS.stat(full)
-            ti = tf.gettarinfo(full, tarname)
-            ti.linkname = fix
-            tf.addfile(ti)
-            skip = True
-
-      ## Nothing special, so just dump the file.  Or whatever it is.
-      if not skip:
+      with U.Escape() as skip:
+        full = OS.path.join(dir, file)
+        tarname = OS.path.join(root, name, file)
+
+        ## Check for symbolic links.  If we find one that points to another
+        ## directory we're going to dump separately then fiddle it so that it
+        ## works in the directory tree we're going to make.
+        if OS.path.islink(full):
+          dest = OS.path.realpath(full)
+          for d, local in dirmap:
+            if dest.startswith(d):
+              fix = OS.path.relpath(OS.path.join('/', local, dest[len(d):]),
+                                    OS.path.join('/', name,
+                                                 OS.path.dirname(file)))
+              st = OS.stat(full)
+              ti = tf.gettarinfo(full, tarname)
+              ti.linkname = fix
+              tf.addfile(ti)
+              skip()
+
+        ## Nothing special, so just dump the file.  Or whatever it is.
         tf.add(full, tarname, recursive = False)
 
 def source(out):