]> arthur.barton.de Git - bup.git/commitdiff
midx: auto-remove midx files that refer to missing .idx files.
authorAvery Pennarun <apenwarr@gmail.com>
Wed, 1 Dec 2010 10:44:18 +0000 (02:44 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Wed, 1 Dec 2010 10:47:45 +0000 (02:47 -0800)
Normally an .idx file doesn't ever disappear, but it could happen if you run
'git gc' on your repository.  Which I thought would be a terrible idea, but
apparently it can actually save a lot of space for some people (although it
takes a pretty long time to run).  And when that happens, all your .idx
files move around.  So let's be polite when that happens.  We'll print a
warning the first time, but then shut up after that since the flawed midx
file will just go away.

Reported by Peter Rabbitson.

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

index 6a51354708f3dcaa61eac472a8a38216499d612d..fc03fe6d9c844004c790878488edf042f704ac02 100644 (file)
@@ -399,7 +399,10 @@ class PackIdxList:
                                 log(('warning: index %s missing\n' +
                                     '  used by %s\n') % (n, mxf))
                                 broken += 1
-                        if not broken:
+                        if broken:
+                            del mx
+                            unlink(full)
+                        else:
                             midxl.append(mx)
                 midxl.sort(lambda x,y: -cmp(len(x),len(y)))
                 for ix in midxl: