File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: storage:: FeedId ;
2
2
use crate :: worker:: Environment ;
3
+ use crate :: worker:: jobs:: InvalidateCdns ;
3
4
use anyhow:: Context ;
4
5
use crates_io_worker:: BackgroundJob ;
5
6
use std:: sync:: Arc ;
@@ -25,8 +26,9 @@ impl BackgroundJob for DeleteCrateFromStorage {
25
26
26
27
async fn run ( & self , ctx : Self :: Context ) -> anyhow:: Result < ( ) > {
27
28
let name = & self . name ;
29
+ let feed_id = FeedId :: Crate { name } ;
28
30
29
- try_join ! (
31
+ let ( crate_file_paths , readme_paths , _ ) = try_join ! (
30
32
async {
31
33
info!( "{name}: Deleting crate files from S3…" ) ;
32
34
let result = ctx. storage. delete_all_crate_files( name) . await ;
@@ -39,13 +41,27 @@ impl BackgroundJob for DeleteCrateFromStorage {
39
41
} ,
40
42
async {
41
43
info!( "{name}: Deleting RSS feed from S3…" ) ;
42
- let feed_id = FeedId :: Crate { name } ;
43
44
let result = ctx. storage. delete_feed( & feed_id) . await ;
44
45
result. context( "Failed to delete RSS feed from S3" )
45
46
}
46
47
) ?;
47
48
48
49
info ! ( "{name}: Successfully deleted crate from S3" ) ;
50
+
51
+ info ! ( "{name}: Enqueuing CDN invalidations" ) ;
52
+
53
+ let mut conn = ctx. deadpool . get ( ) . await ?;
54
+ InvalidateCdns :: new (
55
+ crate_file_paths
56
+ . into_iter ( )
57
+ . chain ( readme_paths. into_iter ( ) )
58
+ . chain ( std:: iter:: once ( object_store:: path:: Path :: from ( & feed_id) ) ) ,
59
+ )
60
+ . enqueue ( & mut conn)
61
+ . await ?;
62
+
63
+ info ! ( "{name}: Successfully enqueued CDN invalidations." ) ;
64
+
49
65
Ok ( ( ) )
50
66
}
51
67
}
You can’t perform that action at this time.
0 commit comments