]> arthur.barton.de Git - bup.git/blobdiff - cmd/index-cmd.py
Restore any metadata during "bup restore"; add "bup meta --edit".
[bup.git] / cmd / index-cmd.py
index a04355096406c837ef29911387aceb3597f04a03..a2df5115492dcdc9b99ee0d6d7f5c01a7cd1e73a 100755 (executable)
@@ -2,7 +2,7 @@
 import sys, stat, time, os
 from bup import options, git, index, drecurse
 from bup.helpers import *
-
+from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
 
 class IterHelper:
     def __init__(self, l):
@@ -49,15 +49,16 @@ def check_index(reader):
 
 
 def update_index(top, excluded_paths):
+    tmax = time.time() - 1
     ri = index.Reader(indexfile)
-    wi = index.Writer(indexfile)
+    wi = index.Writer(indexfile, tmax)
     rig = IterHelper(ri.iter(name=top))
     tstart = int(time.time())
 
     hashgen = None
     if opt.fake_valid:
         def hashgen(name):
-            return (0100644, index.FAKE_SHA)
+            return (GIT_MODE_FILE, index.FAKE_SHA)
 
     total = 0
     bup_dir = os.path.abspath(git.repo())
@@ -101,7 +102,7 @@ def update_index(top, excluded_paths):
                 check_index(ri)
                 log('check: before merging: newfile\n')
                 check_index(wr)
-            mi = index.Writer(indexfile)
+            mi = index.Writer(indexfile, tmax)
 
             for e in index.merge(ri, wr):
                 # FIXME: shouldn't we remove deleted entries eventually?  When?
@@ -145,6 +146,13 @@ if (opt.fake_valid or opt.fake_invalid) and not opt.update:
 if opt.fake_valid and opt.fake_invalid:
     o.fatal('--fake-valid is incompatible with --fake-invalid')
 
+# FIXME: remove this once we account for timestamp races, i.e. index;
+# touch new-file; index.  It's possible for this to happen quickly
+# enough that new-file ends up with the same timestamp as the first
+# index, and then bup will ignore it.
+tick_start = time.time()
+time.sleep(1 - (tick_start - int(tick_start)))
+
 git.check_repo_or_die()
 indexfile = opt.indexfile or git.repo('bupindex')