@@ -6,6 +6,7 @@ use crate::storage::Storage;
6
6
use crate :: utils:: { get_config, get_crate_priority, report_error, set_config, ConfigName } ;
7
7
use crate :: { Config , Index , Metrics , RustwideBuilder } ;
8
8
use anyhow:: Context ;
9
+ use fn_error_context:: context;
9
10
10
11
use tracing:: { debug, error, info, warn} ;
11
12
@@ -69,6 +70,7 @@ impl BuildQueue {
69
70
Ok ( ( ) )
70
71
}
71
72
73
+ #[ context( "error trying to add {name}-{version} to build queue" ) ]
72
74
pub fn add_crate (
73
75
& self ,
74
76
name : & str ,
@@ -342,15 +344,16 @@ impl BuildQueue {
342
344
let yanked = change. yanked ( ) ;
343
345
let unyanked = change. unyanked ( ) ;
344
346
if let Some ( release) = yanked. or ( unyanked) {
345
- // FIXME: https://github.com/rust-lang/docs.rs/issues/1934
346
- // we sometimes have inconsistencies between our yank-state and
347
- // the crates.io yank state, and we don't know why yet.
348
- self . set_yanked (
347
+ // FIXME: delay yanks of crates that have not yet finished building
348
+ // https://github.com/rust-lang/docs.rs/issues/1934
349
+ if let Err ( err) = self . set_yanked (
349
350
& mut conn,
350
351
release. name . as_str ( ) ,
351
352
release. version . as_str ( ) ,
352
353
yanked. is_some ( ) ,
353
- ) ;
354
+ ) {
355
+ report_error ( & err) ;
356
+ }
354
357
355
358
if let Err ( err) =
356
359
cdn:: queue_crate_invalidation ( & mut * conn, & self . config , & release. name )
@@ -372,48 +375,48 @@ impl BuildQueue {
372
375
Ok ( crates_added)
373
376
}
374
377
375
- pub fn set_yanked ( & self , conn : & mut postgres:: Client , name : & str , version : & str , yanked : bool ) {
378
+ #[ context( "error trying to set {name}-{version} to yanked: {yanked}" ) ]
379
+ pub fn set_yanked (
380
+ & self ,
381
+ conn : & mut postgres:: Client ,
382
+ name : & str ,
383
+ version : & str ,
384
+ yanked : bool ,
385
+ ) -> Result < ( ) > {
376
386
let activity = if yanked { "yanked" } else { "unyanked" } ;
377
387
378
- match conn
379
- . execute (
380
- "UPDATE releases
381
- SET yanked = $3
382
- FROM crates
383
- WHERE crates.id = releases.crate_id
384
- AND name = $1
385
- AND version = $2
386
- " ,
387
- & [ & name, & version, & yanked] ,
388
- )
389
- . with_context ( || format ! ( "error while setting {}-{} to {}" , name, version, activity) )
390
- {
391
- Ok ( rows) => {
392
- if rows != 1 {
393
- match self
394
- . has_build_queued ( name, version)
395
- . context ( "error trying to fetch build queue" )
396
- {
397
- Ok ( false ) => {
398
- // the rustwide builder will fetch the current yank state from
399
- // crates.io, so and missed update here will be fixed after the
400
- // build is finished.
401
- error ! (
402
- "tried to yank or unyank non-existing release: {} {}" ,
403
- name, version
404
- ) ;
405
- }
406
- Ok ( true ) => { }
407
- Err ( err) => {
408
- report_error ( & err) ;
409
- }
410
- }
411
- } else {
412
- debug ! ( "{}-{} {}" , name, version, activity) ;
388
+ let rows = conn. execute (
389
+ "UPDATE releases
390
+ SET yanked = $3
391
+ FROM crates
392
+ WHERE crates.id = releases.crate_id
393
+ AND name = $1
394
+ AND version = $2" ,
395
+ & [ & name, & version, & yanked] ,
396
+ ) ?;
397
+ if rows != 1 {
398
+ match self
399
+ . has_build_queued ( name, version)
400
+ . context ( "error trying to fetch build queue" )
401
+ {
402
+ Ok ( false ) => {
403
+ // the rustwide builder will fetch the current yank state from
404
+ // crates.io, so and missed update here will be fixed after the
405
+ // build is finished.
406
+ error ! (
407
+ "tried to yank or unyank non-existing release: {} {}" ,
408
+ name, version
409
+ ) ;
410
+ }
411
+ Ok ( true ) => { }
412
+ Err ( err) => {
413
+ report_error ( & err) ;
413
414
}
414
415
}
415
- Err ( err) => report_error ( & err) ,
416
+ } else {
417
+ debug ! ( "{}-{} {}" , name, version, activity) ;
416
418
}
419
+ Ok ( ( ) )
417
420
}
418
421
419
422
/// Builds the top package from the queue. Returns whether there was a package in the queue.
0 commit comments