From: Avery Pennarun Date: Fri, 23 Jul 2010 07:24:34 +0000 (-0400) Subject: cmd/web: don't die if lresolve() fails. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=6627d423d09194a15bed88e2199ac6e9a5d655ba;p=packages%2Fb%2Fbup.git cmd/web: don't die if lresolve() fails. Some symlinks end up pointing to nonexistent names, which is maybe not "normal", but certainly is allowed. Signed-off-by: Avery Pennarun --- diff --git a/cmd/web-cmd.py b/cmd/web-cmd.py index 52f5468..2ea8c73 100755 --- a/cmd/web-cmd.py +++ b/cmd/web-cmd.py @@ -30,7 +30,7 @@ def _compute_dir_contents(n): # 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 diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index e01c229..e8f2948 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -216,6 +216,13 @@ class Node: #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('')