From: Aidan Hobson Sayers Date: Fri, 17 Jul 2020 21:59:04 +0000 (+0100) Subject: Eliminate redundant check of index start against ctime X-Git-Tag: 0.31~24 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=68e087e6f2f2311ac784b204c0de72dcddb08934 Eliminate redundant check of index start against ctime 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 Reviewed-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/index.py b/lib/bup/index.py index ae62018..051bdb3 100644 --- a/lib/bup/index.py +++ b/lib/bup/index.py @@ -200,7 +200,7 @@ class Entry: 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: @@ -219,10 +219,6 @@ class Entry: 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): diff --git a/lib/cmd/index-cmd.py b/lib/cmd/index-cmd.py index fbaa029..b3925b3 100755 --- a/lib/cmd/index-cmd.py +++ b/lib/cmd/index-cmd.py @@ -85,13 +85,12 @@ def clear_index(indexfile): 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)) - tstart = int(time.time()) * 10**9 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.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: