]> arthur.barton.de Git - bup.git/commitdiff
Eliminate redundant check of index start against ctime
authorAidan Hobson Sayers <aidanhs@cantab.net>
Fri, 17 Jul 2020 21:59:04 +0000 (22:59 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 19 Jul 2020 20:13:15 +0000 (15:13 -0500)
When (the first version of) this check was added 10 years ago in
b4b4ef116880, it was presumably to ensure that "index; save; touch;
index" in the same second would flag a file as needing saving.

Since then, tmax has been added in the indexing process to solve the
problem by capping timestamps stored in the index. This capping means
that a file with ctime in the same second as an indexing start will
be picked up on both the indexes in the example above - there's no need
to special case the check.

Signed-off-by: Aidan Hobson Sayers <aidanhs@cantab.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/index.py
lib/cmd/index-cmd.py

index ae6201853f45b9f4e7dc7816d03cdc7fda8895ec..051bdb372ee33519bcd0fca35827562b59dfc366 100644 (file)
@@ -200,7 +200,7 @@ class Entry:
             log('pack error: %s (%r)\n' % (e, self))
             raise
 
             log('pack error: %s (%r)\n' % (e, self))
             raise
 
-    def stale(self, st, tstart, check_device=True):
+    def stale(self, st, check_device=True):
         if self.size != st.st_size:
             return True
         if self.mtime != st.st_mtime:
         if self.size != st.st_size:
             return True
         if self.mtime != st.st_mtime:
@@ -219,10 +219,6 @@ class Entry:
             return True
         if check_device and (self.dev != st.st_dev):
             return True
             return True
         if check_device and (self.dev != st.st_dev):
             return True
-        # Check that the ctime's "second" is at or after tstart's.
-        ctime_sec_in_ns = xstat.fstime_floor_secs(st.st_ctime) * 10**9
-        if ctime_sec_in_ns >= tstart:
-            return True
         return False
 
     def update_from_stat(self, st, meta_ofs):
         return False
 
     def update_from_stat(self, st, meta_ofs):
index fbaa0299f2d1eab9d7676ffcd1a0da128b6940dd..b3925b3135c0ad90e5780bde535116839926573f 100755 (executable)
@@ -85,13 +85,12 @@ def clear_index(indexfile):
 
 
 def update_index(top, excluded_paths, exclude_rxs, xdev_exceptions, out=None):
 
 
 def update_index(top, excluded_paths, exclude_rxs, xdev_exceptions, out=None):
-    # tmax and start must be epoch nanoseconds.
+    # tmax must be epoch nanoseconds.
     tmax = (time.time() - 1) * 10**9
     ri = index.Reader(indexfile)
     msw = index.MetaStoreWriter(indexfile + b'.meta')
     wi = index.Writer(indexfile, msw, tmax)
     rig = IterHelper(ri.iter(name=top))
     tmax = (time.time() - 1) * 10**9
     ri = index.Reader(indexfile)
     msw = index.MetaStoreWriter(indexfile + b'.meta')
     wi = index.Writer(indexfile, msw, tmax)
     rig = IterHelper(ri.iter(name=top))
-    tstart = int(time.time()) * 10**9
 
     hlinks = hlinkdb.HLinkDB(indexfile + b'.hlink')
 
 
     hlinks = hlinkdb.HLinkDB(indexfile + b'.hlink')
 
@@ -131,7 +130,7 @@ def update_index(top, excluded_paths, exclude_rxs, xdev_exceptions, out=None):
 
         if rig.cur and rig.cur.name == path:    # paths that already existed
             need_repack = False
 
         if rig.cur and rig.cur.name == path:    # paths that already existed
             need_repack = False
-            if(rig.cur.stale(pst, tstart, check_device=opt.check_device)):
+            if(rig.cur.stale(pst, check_device=opt.check_device)):
                 try:
                     meta = metadata.from_path(path, statinfo=pst)
                 except (OSError, IOError) as e:
                 try:
                     meta = metadata.from_path(path, statinfo=pst)
                 except (OSError, IOError) as e: