@@ -68,6 +68,8 @@ pub enum Error {
68
68
NeitherFeatureNorEnvVar ,
69
69
/// Returned when calling methods requiring either a feature or anv var, but both are present
70
70
BothFeatureAndEnvVar ,
71
+ /// Returned when expecting an auto-downloaded executable but `BITCOIND_SKIP_DOWNLOAD` env var is set
72
+ SkipDownload ,
71
73
}
72
74
73
75
impl fmt:: Debug for Error {
@@ -81,6 +83,7 @@ impl fmt::Debug for Error {
81
83
Error :: NoEnvVar => write ! ( f, "Called a method requiring env var `ELECTRUMD_EXE` to be set, but it's not" ) ,
82
84
Error :: NeitherFeatureNorEnvVar => write ! ( f, "Called a method requiring env var `ELECTRUMD_EXE` or a feature to be set, but neither are set" ) ,
83
85
Error :: BothFeatureAndEnvVar => write ! ( f, "Called a method requiring env var `ELECTRUMD_EXE` or a feature to be set, but both are set" ) ,
86
+ Error :: SkipDownload => write ! ( f, "expecting an auto-downloaded executable but `ELECTRUMD_SKIP_DOWNLOAD` env var is set" ) ,
84
87
}
85
88
}
86
89
}
@@ -300,14 +303,16 @@ fn rand_string() -> String {
300
303
301
304
/// Provide the electrum executable path if a version feature has been specified
302
305
pub fn downloaded_exe_path ( ) -> Result < String , Error > {
303
- if versions:: HAS_FEATURE {
306
+ if std:: env:: var_os ( "ELECTRUMD_SKIP_DOWNLOAD" ) . is_some ( ) {
307
+ Err ( Error :: SkipDownload )
308
+ } else if !versions:: HAS_FEATURE {
309
+ Err ( Error :: NoFeature )
310
+ } else {
304
311
Ok ( format ! (
305
312
"{}/electrum/electrum-{}/electrum.AppImage" ,
306
313
env!( "OUT_DIR" ) ,
307
314
versions:: VERSION
308
315
) )
309
- } else {
310
- Err ( Error :: NoFeature )
311
316
}
312
317
}
313
318
@@ -318,7 +323,9 @@ pub fn exe_path() -> Result<String, Error> {
318
323
( Ok ( _) , Ok ( _) ) => Err ( Error :: BothFeatureAndEnvVar ) ,
319
324
( Ok ( path) , Err ( _) ) => Ok ( path) ,
320
325
( Err ( _) , Ok ( path) ) => Ok ( path) ,
321
- ( Err ( _) , Err ( _) ) => Err ( Error :: NeitherFeatureNorEnvVar ) ,
326
+ ( Err ( Error :: NoFeature ) , Err ( _) ) => Err ( Error :: NeitherFeatureNorEnvVar ) ,
327
+ ( Err ( Error :: SkipDownload ) , Err ( _) ) => Err ( Error :: SkipDownload ) ,
328
+ ( Err ( _) , Err ( _) ) => unreachable ! ( ) ,
322
329
}
323
330
}
324
331
0 commit comments