diff hgext/largefiles/lfutil.py @ 48396:c0d88407b7d4

largefile: use the proper "mtime boundary" logic during fixup This will prevent ambiguous cache entry to be used in racy situation. This fix flakiness in test and some real live misbehavior. Differential Revision: https://phab.mercurial-scm.org/D11800
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 23 Nov 2021 18:13:33 +0100
parents 322525db4c98
children 6000f5b25c9b
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py	Tue Nov 23 18:03:51 2021 +0100
+++ b/hgext/largefiles/lfutil.py	Tue Nov 23 18:13:33 2021 +0100
@@ -261,13 +261,10 @@
             st = wctx[lfile].lstat()
             mode = st.st_mode
             size = st.st_size
-            mtime = timestamp.mtime_of(st)
-            cache_data = (mode, size, mtime)
-            # We should consider using the mtime_boundary
-            # logic here, but largefile never actually had
-            # ambiguity protection before, so this confuse
-            # the tests and need more thinking.
-            lfdirstate.set_clean(lfile, cache_data)
+            mtime = timestamp.reliable_mtime_of(st, mtime_boundary)
+            if mtime is not None:
+                cache_data = (mode, size, mtime)
+                lfdirstate.set_clean(lfile, cache_data)
     return s