]> arthur.barton.de Git - bup.git/commitdiff
cmd/web: don't die if lresolve() fails.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 23 Jul 2010 07:24:34 +0000 (03:24 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 23 Jul 2010 07:25:03 +0000 (03:25 -0400)
Some symlinks end up pointing to nonexistent names, which is maybe not
"normal", but certainly is allowed.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/web-cmd.py
lib/bup/vfs.py

index 52f5468daccc42995af45e28356a3dc20edf6f50..2ea8c73683137c5d4d29c6c18a1163750cf27ef6 100755 (executable)
@@ -30,7 +30,7 @@ def _compute_dir_contents(n):
 
         # link should be based on fully resolved type to avoid extra
         # HTTP redirect.
 
         # link should be based on fully resolved type to avoid extra
         # HTTP redirect.
-        if stat.S_ISDIR(sub.lresolve('').mode):
+        if stat.S_ISDIR(sub.try_lresolve('').mode):
             link = sub.name + "/"
 
         size = None
             link = sub.name + "/"
 
         size = None
index e01c229b498a3816b1ed566625bf5dfa2a1f8192..e8f29489310edf8d9855492d380e7667864f3ae6 100644 (file)
@@ -216,6 +216,13 @@ class Node:
         #log('parts: %r %r\n' % (path, parts))
         return start._lresolve(parts)
 
         #log('parts: %r %r\n' % (path, parts))
         return start._lresolve(parts)
 
+    def try_lresolve(self, path):
+        try:
+            return self.lresolve(path)
+        except NoSuchFile:
+            # some symlinks don't actually point at a file that exists!
+            return self
+
     def resolve(self, path):
         return self.lresolve(path).lresolve('')
     
     def resolve(self, path):
         return self.lresolve(path).lresolve('')