@@ -3,7 +3,6 @@ use anyhow::{Context, Result};
3
3
use once_cell:: sync:: Lazy ;
4
4
use regex:: Regex ;
5
5
use std:: path:: { Path , PathBuf } ;
6
- use tokio:: fs;
7
6
8
7
static VERSION_REGEX : Lazy < Regex > =
9
8
Lazy :: new ( || Regex :: new ( r"\d{4}\.\d+(-beta\d+)?(-dev)?-([0-9a-z])+" ) . unwrap ( ) ) ;
@@ -19,34 +18,21 @@ pub struct Manifest {
19
18
/// If it's a path, use the path.
20
19
/// If it corresponds to a file in packages/, use that package.
21
20
/// TODO: If it's a git tag or rev, download it.
22
- pub async fn get_app_manifest (
21
+ pub fn get_app_manifest (
23
22
config : & VmConfig ,
24
23
app_package : String ,
25
24
app_package_to_upgrade_from : Option < String > ,
26
25
package_folder : Option < PathBuf > ,
27
26
) -> Result < Manifest > {
28
27
let package_type = ( config. os_type , config. package_type , config. architecture ) ;
29
28
30
- let app_package_path =
31
- find_app ( & app_package, false , package_type, package_folder. as_ref ( ) ) . await ?;
29
+ let app_package_path = find_app ( & app_package, false , package_type, package_folder. as_ref ( ) ) ?;
32
30
log:: info!( "Current app: {}" , app_package_path. display( ) ) ;
33
31
34
- let app_package_to_upgrade_from_path =
35
- if let Some ( app_package_to_upgrade_from) = app_package_to_upgrade_from {
36
- log:: info!( "Previous app: {}" , app_package_to_upgrade_from) ;
37
- Some (
38
- find_app (
39
- & app_package_to_upgrade_from,
40
- false ,
41
- package_type,
42
- package_folder. as_ref ( ) ,
43
- )
44
- . await ?,
45
- )
46
- } else {
47
- log:: warn!( "No previous app version specified" ) ;
48
- None
49
- } ;
32
+ let app_package_to_upgrade_from_path = app_package_to_upgrade_from
33
+ . map ( |app| find_app ( & app, false , package_type, package_folder. as_ref ( ) ) )
34
+ . transpose ( ) ?;
35
+ log:: info!( "Previous app: {app_package_to_upgrade_from_path:?}" ) ;
50
36
51
37
let capture = VERSION_REGEX
52
38
. captures ( app_package_path. to_str ( ) . unwrap ( ) )
@@ -55,14 +41,8 @@ pub async fn get_app_manifest(
55
41
. map ( |c| c. as_str ( ) )
56
42
. expect ( "Could not parse version from package name: {app_package}" ) ;
57
43
58
- let ui_e2e_tests_path = find_app ( capture, true , package_type, package_folder. as_ref ( ) )
59
- . await
60
- . ok ( ) ;
61
- if let Some ( ui_e2e_tests_path) = & ui_e2e_tests_path {
62
- log:: info!( "GUI e2e test binary: {}" , ui_e2e_tests_path. display( ) ) ;
63
- } else {
64
- log:: warn!( "Could not find UI e2e test binary" ) ;
65
- }
44
+ let ui_e2e_tests_path = find_app ( capture, true , package_type, package_folder. as_ref ( ) ) . ok ( ) ;
45
+ log:: info!( "GUI e2e test binary: {ui_e2e_tests_path:?}" ) ;
66
46
67
47
Ok ( Manifest {
68
48
app_package_path,
@@ -71,7 +51,7 @@ pub async fn get_app_manifest(
71
51
} )
72
52
}
73
53
74
- async fn find_app (
54
+ fn find_app (
75
55
app : & str ,
76
56
e2e_bin : bool ,
77
57
package_type : ( OsType , Option < PackageType > , Option < Architecture > ) ,
@@ -89,14 +69,12 @@ async fn find_app(
89
69
90
70
let current_dir = std:: env:: current_dir ( ) . expect ( "Unable to get current directory" ) ;
91
71
let packages_dir = package_folder. unwrap_or ( & current_dir) ;
92
- fs:: create_dir_all ( & packages_dir) . await ?;
93
- let mut dir = fs:: read_dir ( packages_dir. clone ( ) )
94
- . await
95
- . context ( "Failed to list packages" ) ?;
72
+ std:: fs:: create_dir_all ( packages_dir) ?;
73
+ let mut dir = std:: fs:: read_dir ( packages_dir. clone ( ) ) . context ( "Failed to list packages" ) ?;
96
74
97
75
let mut matches = vec ! [ ] ;
98
76
99
- while let Ok ( Some ( entry) ) = dir. next_entry ( ) . await {
77
+ while let Some ( Ok ( entry) ) = dir. next ( ) {
100
78
let path = entry. path ( ) ;
101
79
if !path. is_file ( ) {
102
80
continue ;
0 commit comments