]> arthur.barton.de Git - bup.git/commitdiff
cmd/index: catch exception for paths that don't exist.
authorDavid Roda <davidcroda@gmail.com>
Tue, 31 Aug 2010 22:25:34 +0000 (18:25 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Sun, 5 Sep 2010 20:51:49 +0000 (13:51 -0700)
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 <davidcroda@gmail.com>
Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/index-cmd.py
lib/bup/drecurse.py
lib/bup/index.py

index be064fb3f79739fc7d5ac08fcb7f8db4eb7331fe..47dbd22bc5d57e5bd08aecc9c44f4b87e41c4e43 100755 (executable)
@@ -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)
index 169aa31c64f549e77799381ed044d5672910e184..ac0115e9f1685c965fad86bf883e44a045a72383 100644 (file)
@@ -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)
index 623b2d6c71e5ed83f6469fba4a9448eb2a3dfe85..c6329c48948430a5a6780bf4eb91958a063ec960 100644 (file)
@@ -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 = []