210
210
flush -- discard any previous cache and recalculate from scratch.
213
# load the existing cache; use information there to find a list of
214
# files ordered by inode, which is alleged to be the fastest order
214
# TODO: It's supposed to be faster to stat the files in order by inum.
215
# We don't directly know the inum of the files of course but we do
216
# know where they were last sighted, so we can sort by that.
217
to_update = _files_from_inventory(inv)
218
219
assert isinstance(flush, bool)
222
223
cache = load_cache(basedir)
223
return _update_cache_from_list(basedir, cache, _files_from_inventory(inv))
227
def _update_cache_from_list(basedir, cache, to_update):
228
"""Update and return the cache for given files.
230
cache -- Previously cached values to be validated.
232
to_update -- Sequence of (file_id, path) pairs to check.
234
stat_cnt = missing_cnt = hardcheck = change_cnt = 0
227
for file_id, path in to_update:
229
by_inode.append((cache[file_id][SC_INO], file_id, path))
231
without_inode.append((file_id, path))
234
to_update = [a[1:] for a in by_inode] + without_inode
236
stat_cnt = missing_cnt = new_cnt = hardcheck = change_cnt = 0
236
238
# dangerfiles have been recently touched and can't be committed to
237
239
# a persistent cache yet, but they are returned to the caller.
274
278
mutter('statcache: statted %d files, read %d files, %d changed, %d dangerous, '
279
'%d deleted, %d new, '
276
% (stat_cnt, hardcheck, change_cnt, len(dangerfiles), len(cache)))
281
% (stat_cnt, hardcheck, change_cnt, len(dangerfiles),
282
missing_cnt, new_cnt, len(cache)))
279
285
mutter('updating on-disk statcache')