File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change
1
+ use anyhow:: anyhow;
1
2
use std:: sync:: Arc ;
2
3
3
4
use crates_io_worker:: BackgroundJob ;
4
5
use diesel:: PgConnection ;
5
6
use typomania:: Package ;
6
7
7
8
use crate :: email:: Email ;
8
- use crate :: tasks:: spawn_blocking;
9
9
use crate :: {
10
10
typosquat:: { Cache , Crate } ,
11
11
worker:: Environment ,
@@ -34,12 +34,13 @@ impl BackgroundJob for CheckTyposquat {
34
34
async fn run ( & self , env : Self :: Context ) -> anyhow:: Result < ( ) > {
35
35
let crate_name = self . name . clone ( ) ;
36
36
37
- spawn_blocking ( move || {
38
- let mut conn = env . connection_pool . get ( ) ? ;
39
- let cache = env. typosquat_cache ( & mut conn) ?;
40
- check ( & env. emails , cache, & mut conn, & crate_name)
37
+ let conn = env . deadpool . get ( ) . await ? ;
38
+ conn. interact ( move |conn| {
39
+ let cache = env. typosquat_cache ( conn) ?;
40
+ check ( & env. emails , cache, conn, & crate_name)
41
41
} )
42
42
. await
43
+ . map_err ( |err| anyhow ! ( err. to_string( ) ) ) ?
43
44
}
44
45
}
45
46
You can’t perform that action at this time.
0 commit comments