@@ -269,7 +269,12 @@ impl<'cfg> HttpRegistry<'cfg> {
269
269
} ;
270
270
for ( token, result) in results {
271
271
let ( mut download, handle) = self . downloads . pending . remove ( & token) . unwrap ( ) ;
272
- assert ! ( self . downloads. pending_paths. remove( & download. path) ) ;
272
+ let was_present = self . downloads . pending_paths . remove ( & download. path ) ;
273
+ assert ! (
274
+ was_present,
275
+ "expected pending_paths to contain {:?}" ,
276
+ download. path
277
+ ) ;
273
278
let mut handle = self . multi . remove ( handle) ?;
274
279
let data = download. data . take ( ) ;
275
280
let url = self . full_url ( & download. path ) ;
@@ -403,17 +408,10 @@ impl<'cfg> HttpRegistry<'cfg> {
403
408
for ( dl, handle) in self . downloads . sleeping . to_retry ( ) {
404
409
let mut handle = self . multi . add ( handle) ?;
405
410
handle. set_token ( dl. token ) ?;
406
- assert ! (
407
- self . downloads. pending_paths. insert( dl. path. to_path_buf( ) ) ,
408
- "path queued for download more than once"
409
- ) ;
410
- assert ! (
411
- self . downloads
412
- . pending
413
- . insert( dl. token, ( dl, handle) )
414
- . is_none( ) ,
415
- "dl token queued more than once"
416
- ) ;
411
+ let is_new = self . downloads . pending_paths . insert ( dl. path . to_path_buf ( ) ) ;
412
+ assert ! ( is_new, "path queued for download more than once" ) ;
413
+ let previous = self . downloads . pending . insert ( dl. token , ( dl, handle) ) ;
414
+ assert ! ( previous. is_none( ) , "dl token queued more than once" ) ;
417
415
}
418
416
Ok ( ( ) )
419
417
}
@@ -477,8 +475,9 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
477
475
let result =
478
476
result. with_context ( || format ! ( "download of {} failed" , path. display( ) ) ) ?;
479
477
478
+ let is_new = self . fresh . insert ( path. to_path_buf ( ) ) ;
480
479
assert ! (
481
- self . fresh . insert ( path . to_path_buf ( ) ) ,
480
+ is_new ,
482
481
"downloaded the index file `{}` twice" ,
483
482
path. display( )
484
483
) ;
@@ -634,10 +633,8 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
634
633
let token = self . downloads . next ;
635
634
self . downloads . next += 1 ;
636
635
debug ! ( "downloading {} as {}" , path. display( ) , token) ;
637
- assert ! (
638
- self . downloads. pending_paths. insert( path. to_path_buf( ) ) ,
639
- "path queued for download more than once"
640
- ) ;
636
+ let is_new = self . downloads . pending_paths . insert ( path. to_path_buf ( ) ) ;
637
+ assert ! ( is_new, "path queued for download more than once" ) ;
641
638
642
639
// Each write should go to self.downloads.pending[&token].data.
643
640
// Since the write function must be 'static, we access downloads through a thread-local.
0 commit comments