Skip to content

Commit

Permalink
Eliminate redundant check of index start against ctime
Browse files Browse the repository at this point in the history
When (the first version of) this check was added 10 years ago in
b4b4ef1, 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 <[email protected]>
Reviewed-by: Rob Browning <[email protected]>
Tested-by: Rob Browning <[email protected]>
  • Loading branch information
aidanhs authored and rlbdv committed Jul 19, 2020
1 parent eadddb9 commit 68e087e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 1 addition & 5 deletions lib/bup/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def packed(self):
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:
Expand All @@ -219,10 +219,6 @@ def stale(self, st, tstart, check_device=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):
Expand Down
5 changes: 2 additions & 3 deletions lib/cmd/index-cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -131,7 +130,7 @@ def fake_hash(name):

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:
Expand Down

0 comments on commit 68e087e

Please sign in to comment.