Exemple #1
0
def diff_file_stats(file_stats, history_entries, groupids, slog):
    with slog.time("group history by path") as rt:
        history_by_gpath = group_history_by_gpath(history_entries)
        rt.set_result({"path count": len(history_by_gpath)})

    with slog.time("compare to latest history"):
        for (rpath, size, mtime) in file_stats:
            groupid = groupids.from_root(rpath.root)
            if groupid is None:
                slog.ignored_rpath_without_groupid(rpath)
            else:
                gpath = (groupid, rpath.rel)
                history = history_by_gpath.pop(gpath, None)
                if history is None:
                    yield FileDiff.created(gpath, rpath, size, mtime, None)
                else:
                    latest = history.latest
                    if latest.size != size \
                           or not mtimes_eq(latest.mtime, mtime):
                        yield FileDiff.changed(gpath, rpath, size, mtime, None)
                    else:
                        pass # unchanged

    with slog.time("find missing paths"):
        for missing_gpath, missing_history in history_by_gpath.iteritems():
            if not missing_history.latest.deleted:
                (groupid, path) = missing_gpath
                root = groupids.to_root(groupid)
                if root is None:
                    slog.ignored_gpath_without_root(missing_gpath)
                else:
                    yield FileDiff.deleted(
                        missing_gpath, RootedPath(root, path),
                        DELETED_SIZE, DELETED_MTIME, "")
Exemple #2
0
 def is_stable(fdiff):
     (rescan_size, rescan_mtime) = rescan_stats_by_rpath.get(
         fdiff.rpath, (DELETED_SIZE, DELETED_MTIME))
     return fdiff.size == rescan_size and \
            mtimes_eq(fdiff.mtime, rescan_mtime)