160
160
161
161
use std:: borrow:: Cow ;
162
162
use std:: collections:: BTreeMap ;
163
+ use std:: collections:: HashSet ;
163
164
use std:: io:: Write ;
164
165
use std:: path:: { Path , PathBuf } ;
165
166
@@ -192,6 +193,7 @@ pub struct RegistrySource<'cfg> {
192
193
updated : bool ,
193
194
ops : Box < dyn RegistryData + ' cfg > ,
194
195
index : index:: RegistryIndex < ' cfg > ,
196
+ yanked_whitelist : HashSet < PackageId > ,
195
197
index_locked : bool ,
196
198
}
197
199
@@ -385,23 +387,42 @@ fn short_name(id: SourceId) -> String {
385
387
}
386
388
387
389
impl < ' cfg > RegistrySource < ' cfg > {
388
- pub fn remote ( source_id : SourceId , config : & ' cfg Config ) -> RegistrySource < ' cfg > {
390
+ pub fn remote (
391
+ source_id : SourceId ,
392
+ yanked_whitelist : HashSet < PackageId > ,
393
+ config : & ' cfg Config ,
394
+ ) -> RegistrySource < ' cfg > {
389
395
let name = short_name ( source_id) ;
390
396
let ops = remote:: RemoteRegistry :: new ( source_id, config, & name) ;
391
- RegistrySource :: new ( source_id, config, & name, Box :: new ( ops) , true )
397
+ RegistrySource :: new (
398
+ source_id,
399
+ config,
400
+ & name,
401
+ Box :: new ( ops) ,
402
+ yanked_whitelist,
403
+ true ,
404
+ )
392
405
}
393
406
394
407
pub fn local ( source_id : SourceId , path : & Path , config : & ' cfg Config ) -> RegistrySource < ' cfg > {
395
408
let name = short_name ( source_id) ;
396
409
let ops = local:: LocalRegistry :: new ( path, config, & name) ;
397
- RegistrySource :: new ( source_id, config, & name, Box :: new ( ops) , false )
410
+ RegistrySource :: new (
411
+ source_id,
412
+ config,
413
+ & name,
414
+ Box :: new ( ops) ,
415
+ HashSet :: new ( ) ,
416
+ false ,
417
+ )
398
418
}
399
419
400
420
fn new (
401
421
source_id : SourceId ,
402
422
config : & ' cfg Config ,
403
423
name : & str ,
404
424
ops : Box < dyn RegistryData + ' cfg > ,
425
+ yanked_whitelist : HashSet < PackageId > ,
405
426
index_locked : bool ,
406
427
) -> RegistrySource < ' cfg > {
407
428
RegistrySource {
@@ -410,6 +431,7 @@ impl<'cfg> RegistrySource<'cfg> {
410
431
source_id,
411
432
updated : false ,
412
433
index : index:: RegistryIndex :: new ( source_id, ops. index_path ( ) , config, index_locked) ,
434
+ yanked_whitelist,
413
435
index_locked,
414
436
ops,
415
437
}
@@ -431,9 +453,7 @@ impl<'cfg> RegistrySource<'cfg> {
431
453
// unpacked and to lock the directory for unpacking.
432
454
let mut ok = {
433
455
let package_dir = format ! ( "{}-{}" , pkg. name( ) , pkg. version( ) ) ;
434
- let dst = self
435
- . src_path
436
- . join ( & package_dir) ;
456
+ let dst = self . src_path . join ( & package_dir) ;
437
457
dst. create_dir ( ) ?;
438
458
439
459
// Attempt to open a read-only copy first to avoid an exclusive write
@@ -526,12 +546,13 @@ impl<'cfg> Source for RegistrySource<'cfg> {
526
546
if dep. source_id ( ) . precise ( ) . is_some ( ) && !self . updated {
527
547
debug ! ( "attempting query without update" ) ;
528
548
let mut called = false ;
529
- self . index . query_inner ( dep, & mut * self . ops , & mut |s| {
530
- if dep. matches ( & s) {
531
- called = true ;
532
- f ( s) ;
533
- }
534
- } ) ?;
549
+ self . index
550
+ . query_inner ( dep, & mut * self . ops , & self . yanked_whitelist , & mut |s| {
551
+ if dep. matches ( & s) {
552
+ called = true ;
553
+ f ( s) ;
554
+ }
555
+ } ) ?;
535
556
if called {
536
557
return Ok ( ( ) ) ;
537
558
} else {
@@ -540,15 +561,17 @@ impl<'cfg> Source for RegistrySource<'cfg> {
540
561
}
541
562
}
542
563
543
- self . index . query_inner ( dep, & mut * self . ops , & mut |s| {
544
- if dep. matches ( & s) {
545
- f ( s) ;
546
- }
547
- } )
564
+ self . index
565
+ . query_inner ( dep, & mut * self . ops , & self . yanked_whitelist , & mut |s| {
566
+ if dep. matches ( & s) {
567
+ f ( s) ;
568
+ }
569
+ } )
548
570
}
549
571
550
572
fn fuzzy_query ( & mut self , dep : & Dependency , f : & mut dyn FnMut ( Summary ) ) -> CargoResult < ( ) > {
551
- self . index . query_inner ( dep, & mut * self . ops , f)
573
+ self . index
574
+ . query_inner ( dep, & mut * self . ops , & self . yanked_whitelist , f)
552
575
}
553
576
554
577
fn supports_checksums ( & self ) -> bool {
0 commit comments