@@ -58,6 +58,8 @@ pub struct Settings {
5858 pub timeout : Option < Duration > ,
5959 /// Server configuration options
6060 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 ,
6163}
6264
6365/// Settings implementation
@@ -109,6 +111,7 @@ impl Settings {
109111 temporary : true ,
110112 timeout : Some ( Duration :: from_secs ( 5 ) ) ,
111113 configuration : HashMap :: new ( ) ,
114+ trust_installation_dir : false ,
112115 }
113116 }
114117
@@ -190,6 +193,9 @@ impl Settings {
190193 }
191194 } ;
192195 }
196+ if let Some ( trust_installation_dir) = query_parameters. get ( "trust_installation_dir" ) {
197+ settings. trust_installation_dir = trust_installation_dir == "true" ;
198+ }
193199 let configuration_prefix = "configuration." ;
194200 for ( key, value) in & query_parameters {
195201 if key. starts_with ( configuration_prefix) {
@@ -296,10 +302,11 @@ mod tests {
296302 let password_file = "password_file=/tmp/.pgpass" ;
297303 let data_dir = "data_dir=/tmp/data" ;
298304 let temporary = "temporary=false" ;
305+ let trust_installation_dir = "trust_installation_dir=true" ;
299306 let timeout = "timeout=10" ;
300307 let configuration = "configuration.max_connections=42" ;
301308 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}"
303310 ) ;
304311
305312 let settings = Settings :: from_url ( url) ?;
@@ -314,6 +321,7 @@ mod tests {
314321 assert_eq ! ( BOOTSTRAP_SUPERUSER , settings. username) ;
315322 assert_eq ! ( "password" , settings. password) ;
316323 assert ! ( !settings. temporary) ;
324+ assert ! ( settings. trust_installation_dir) ;
317325 assert_eq ! ( Some ( Duration :: from_secs( 10 ) ) , settings. timeout) ;
318326 let configuration = HashMap :: from ( [ ( "max_connections" . to_string ( ) , "42" . to_string ( ) ) ] ) ;
319327 assert_eq ! ( configuration, settings. configuration) ;
0 commit comments