From 94c3b43be36773624aa073583806751bb97ba023 Mon Sep 17 00:00:00 2001 From: David Roda Date: Tue, 31 Aug 2010 18:25:34 -0400 Subject: [PATCH] cmd/index: catch exception for paths that don't exist. Rather than aborting completely if a path specified on the command line doesn't exist, report it as a non-fatal error instead. (Heavily modified by apenwarr from David Roda's original patch.) Signed-off-by: David Roda Signed-off-by: Avery Pennarun --- cmd/index-cmd.py | 2 +- lib/bup/drecurse.py | 2 +- lib/bup/index.py | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/index-cmd.py b/cmd/index-cmd.py index be064fb..47dbd22 100755 --- a/cmd/index-cmd.py +++ b/cmd/index-cmd.py @@ -152,7 +152,7 @@ if opt.check: paths = index.reduce_paths(extra) if opt.update: - if not paths: + if not extra: o.fatal('update (-u) requested but no paths given') for (rp,path) in paths: update_index(rp) diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py index 169aa31..ac0115e 100644 --- a/lib/bup/drecurse.py +++ b/lib/bup/drecurse.py @@ -73,7 +73,7 @@ def recursive_dirlist(paths, xdev): yield (path, pst) continue except OSError, e: - add_error(e) + add_error('recursive_dirlist: %s' % e) continue try: pfile = OsFile(path) diff --git a/lib/bup/index.py b/lib/bup/index.py index 623b2d6..c6329c4 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -404,11 +404,14 @@ def reduce_paths(paths): xpaths = [] for p in paths: rp = realpath(p) - st = os.lstat(rp) - if stat.S_ISDIR(st.st_mode): - rp = slashappend(rp) - p = slashappend(p) - xpaths.append((rp, p)) + try: + st = os.lstat(rp) + if stat.S_ISDIR(st.st_mode): + rp = slashappend(rp) + p = slashappend(p) + xpaths.append((rp, p)) + except OSError, e: + add_error('reduce_paths: %s' % e) xpaths.sort() paths = [] -- 2.39.2