@@ -40,7 +40,7 @@ package body GNATCOLL.File_Indexes is
4040 Attrs : Stat.File_Attributes;
4141 State : out Entry_State;
4242 Digest : out File_Index_Digest;
43- Trust_Cache : Boolean := False);
43+ Force_Cache : Boolean := False);
4444
4545 -- ---------------
4646 -- Clear_Cache --
@@ -59,7 +59,7 @@ package body GNATCOLL.File_Indexes is
5959 function Hash
6060 (Self : in out File_Index;
6161 Path : UTF8.UTF_8_String;
62- Trust_Cache : Boolean := False)
62+ Force_Cache : Boolean := False)
6363 return File_Index_Digest
6464 is
6565 State : Entry_State;
@@ -70,7 +70,7 @@ package body GNATCOLL.File_Indexes is
7070 Path => Path,
7171 State => State,
7272 Digest => Digest,
73- Trust_Cache => Trust_Cache );
73+ Force_Cache => Force_Cache );
7474 return Digest;
7575 end Hash ;
7676
@@ -79,7 +79,7 @@ package body GNATCOLL.File_Indexes is
7979 Path : UTF8.UTF_8_String;
8080 State : out Entry_State;
8181 Digest : out File_Index_Digest;
82- Trust_Cache : Boolean := False)
82+ Force_Cache : Boolean := False)
8383 is
8484 Normalized_Path : constant String := GNAT.OS_Lib.Normalize_Pathname
8585 (Path, Resolve_Links => False);
@@ -90,7 +90,7 @@ package body GNATCOLL.File_Indexes is
9090 Stat.Stat (Normalized_Path),
9191 State,
9292 Digest,
93- Trust_Cache );
93+ Force_Cache );
9494 end Hash ;
9595
9696 procedure Hash
@@ -99,7 +99,7 @@ package body GNATCOLL.File_Indexes is
9999 Attrs : Stat.File_Attributes;
100100 State : out Entry_State;
101101 Digest : out File_Index_Digest;
102- Trust_Cache : Boolean := False)
102+ Force_Cache : Boolean := False)
103103 is
104104 begin
105105 Internal_Hash
@@ -108,7 +108,7 @@ package body GNATCOLL.File_Indexes is
108108 Attrs,
109109 State,
110110 Digest,
111- Trust_Cache );
111+ Force_Cache );
112112 end Hash ;
113113
114114 -- -----------------
@@ -121,7 +121,7 @@ package body GNATCOLL.File_Indexes is
121121 Attrs : Stat.File_Attributes;
122122 State : out Entry_State;
123123 Digest : out File_Index_Digest;
124- Trust_Cache : Boolean := False)
124+ Force_Cache : Boolean := False)
125125 is
126126 use File_Maps;
127127 use type Stat.File_Attributes;
@@ -138,7 +138,15 @@ package body GNATCOLL.File_Indexes is
138138 if Prev_Cursor /= No_Element then
139139 Prev := Element (Prev_Cursor);
140140
141- if Prev.Trust_Hash and then Attrs = Prev.Attrs then
141+ -- If Force_Cache is set, we want to ensure the recomputation of the
142+ -- checksum. This allows to force the update of the cache even though
143+ -- the previous checksum was tagged as trusted. The file could have
144+ -- been modified without Stat picking up the change if the file
145+ -- systems do not have the sufficient time resolution.
146+ if not Force_Cache
147+ and then Prev.Trust_Hash
148+ and then Attrs = Prev.Attrs
149+ then
142150 State := UNCHANGED_FILE;
143151 Digest := Prev.Hash_Digest;
144152
@@ -196,7 +204,7 @@ package body GNATCOLL.File_Indexes is
196204 -- the File_Index DB. In those cases don't trust the hash (i.e: always
197205 -- recompute it in the next query), unless the caller explicitly specify
198206 -- that the value is to be trusted.
199- Trust_New_Hash := Trust_Cache
207+ Trust_New_Hash := Force_Cache
200208 or else (Ada.Calendar.Clock - Stat.Modification_Time (Attrs)) > 1.0 ;
201209
202210 -- Add the new entry
0 commit comments