]> arthur.barton.de Git - bup.git/blobdiff - cmd/gc-cmd.py
rm: move core code to bup.rm module
[bup.git] / cmd / gc-cmd.py
index dfb75a90668383b575a0460c19a3b64272ce8538..90874c3ee03009c1ac29fea8c35014b7d65384df 100755 (executable)
@@ -1,7 +1,12 @@
-#!/usr/bin/env python
+#!/bin/sh
+"""": # -*-python-*-
+bup_python="$(dirname "$0")/bup-python" || exit $?
+exec "$bup_python" "$0" ${1+"$@"}
+"""
+# end of bup preamble
 import glob, os, stat, subprocess, sys, tempfile
 from bup import bloom, git, midx, options, vfs
-from bup.git import walk_object
+from bup.git import MissingObject, walk_object
 from bup.helpers import handle_ctrl_c, log, progress, qprogress, saved_errors
 from os.path import basename
 
@@ -45,7 +50,7 @@ optspec = """
 bup gc [options...]
 --
 v,verbose   increase log output (can be used more than once)
-threshold   only rewrite a packfile if it's over this percent garbage [10]
+threshold=  only rewrite a packfile if it's over this percent garbage [10]
 #,compress= set compression level to # (0-9, 9 is highest) [1]
 unsafe      use the command even though it may be DANGEROUS
 """
@@ -255,7 +260,11 @@ if not existing_count:
     if opt.verbose:
         log('nothing to collect\n')
 else:
-    live_objects = find_live_objects(existing_count, cat_pipe, opt)
+    try:
+        live_objects = find_live_objects(existing_count, cat_pipe, opt)
+    except MissingObject as ex:
+        log('bup: missing object %r \n' % ex.id.encode('hex'))
+        sys.exit(1)
     try:
         # FIXME: just rename midxes and bloom, and restore them at the end if
         # we didn't change any packs?