@@ -58,6 +58,8 @@ pub struct Settings {
58
58
pub timeout : Option < Duration > ,
59
59
/// Server configuration options
60
60
pub configuration : HashMap < String , String > ,
61
+ /// Skip installation and inferrence of the installation dir. Trust what the user provided.
62
+ pub trust_installation_dir : bool ,
61
63
}
62
64
63
65
/// Settings implementation
@@ -109,6 +111,7 @@ impl Settings {
109
111
temporary : true ,
110
112
timeout : Some ( Duration :: from_secs ( 5 ) ) ,
111
113
configuration : HashMap :: new ( ) ,
114
+ trust_installation_dir : false ,
112
115
}
113
116
}
114
117
@@ -190,6 +193,9 @@ impl Settings {
190
193
}
191
194
} ;
192
195
}
196
+ if let Some ( trust_installation_dir) = query_parameters. get ( "trust_installation_dir" ) {
197
+ settings. trust_installation_dir = trust_installation_dir == "true" ;
198
+ }
193
199
let configuration_prefix = "configuration." ;
194
200
for ( key, value) in & query_parameters {
195
201
if key. starts_with ( configuration_prefix) {
@@ -296,10 +302,11 @@ mod tests {
296
302
let password_file = "password_file=/tmp/.pgpass" ;
297
303
let data_dir = "data_dir=/tmp/data" ;
298
304
let temporary = "temporary=false" ;
305
+ let trust_installation_dir = "trust_installation_dir=true" ;
299
306
let timeout = "timeout=10" ;
300
307
let configuration = "configuration.max_connections=42" ;
301
308
let url = format ! (
302
- "{base_url}?{releases_url}&{version}&{installation_dir}&{password_file}&{data_dir}&{temporary}&{temporary }&{timeout}&{configuration}"
309
+ "{base_url}?{releases_url}&{version}&{installation_dir}&{password_file}&{data_dir}&{temporary}&{trust_installation_dir }&{timeout}&{configuration}"
303
310
) ;
304
311
305
312
let settings = Settings :: from_url ( url) ?;
@@ -314,6 +321,7 @@ mod tests {
314
321
assert_eq ! ( BOOTSTRAP_SUPERUSER , settings. username) ;
315
322
assert_eq ! ( "password" , settings. password) ;
316
323
assert ! ( !settings. temporary) ;
324
+ assert ! ( settings. trust_installation_dir) ;
317
325
assert_eq ! ( Some ( Duration :: from_secs( 10 ) ) , settings. timeout) ;
318
326
let configuration = HashMap :: from ( [ ( "max_connections" . to_string ( ) , "42" . to_string ( ) ) ] ) ;
319
327
assert_eq ! ( configuration, settings. configuration) ;
0 commit comments