@@ -163,10 +163,9 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
163
163
// Older versions of Cargo used the single value of the hash of the HEAD commit as a `index_version`.
164
164
// This is technically correct but a little too conservative. If a new commit is fetched all cached
165
165
// files need to be regenerated even if a particular file was not changed.
166
- // Cargo now reads the `index_version` in two parts the cache file is considered valid if `index_version`
166
+ // Cargo now checks the `index_version` in two parts the cache file is considered valid if `index_version`
167
167
// ends with the hash of the HEAD commit OR if it starts with the hash of the file's contents.
168
- // In the future cargo can write cached files with `index_version` = `git_file_hash + ":" + `git_commit_hash`,
169
- // but for now it still uses `git_commit_hash` to be compatible with older Cargoes.
168
+ // Cargo writes the cached files with `index_version` = `git_file_hash` + ":" + `git_commit_hash`.
170
169
fn load (
171
170
& mut self ,
172
171
_root : & Path ,
@@ -178,7 +177,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
178
177
}
179
178
// Check if the cache is valid.
180
179
let git_commit_hash = self . current_version ( ) ;
181
- if let ( Some ( c ) , Some ( i ) ) = ( git_commit_hash , index_version ) {
180
+ if let ( Some ( i ) , Some ( c ) ) = ( index_version , git_commit_hash ) {
182
181
if i. ends_with ( c. as_str ( ) ) {
183
182
return Poll :: Ready ( Ok ( LoadResponse :: CacheValid ) ) ;
184
183
}
@@ -212,9 +211,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
212
211
213
212
Ok ( LoadResponse :: Data {
214
213
raw_data : blob. content ( ) . to_vec ( ) ,
215
- index_version : git_commit_hash. map ( String :: from) ,
216
- // TODO: When the reading code has been stable for long enough (Say 8/2022)
217
- // change to `git_file_hash + ":" + git_commit_hash`
214
+ index_version : git_commit_hash. map ( |c| git_file_hash + c) ,
218
215
} )
219
216
}
220
217
0 commit comments