1
1
use crate :: error:: Error :: { DatabaseInitializationError , DatabaseStartError , DatabaseStopError } ;
2
2
use crate :: error:: Result ;
3
3
use crate :: settings:: { BOOTSTRAP_DATABASE , BOOTSTRAP_SUPERUSER , Settings } ;
4
- use postgresql_archive:: get_version;
5
- use postgresql_archive:: { ExactVersion , ExactVersionReq } ;
6
- use postgresql_archive:: { extract, get_archive} ;
4
+ use std:: fmt:: Debug ;
5
+
6
+ use postgresql_archive:: { ExactVersion , extract} ;
7
+ #[ cfg( not( feature = "bundled" ) ) ]
8
+ use postgresql_archive:: { ExactVersionReq , get_archive, get_version} ;
7
9
#[ cfg( feature = "tokio" ) ]
8
10
use postgresql_commands:: AsyncCommandExecutor ;
9
11
use postgresql_commands:: CommandBuilder ;
@@ -186,12 +188,20 @@ impl PostgreSQL {
186
188
// If the exact version is not set, determine the latest version and update the version and
187
189
// installation directory accordingly. This is an optimization to avoid downloading the
188
190
// archive if the latest version is already installed.
191
+ #[ cfg( not( feature = "bundled" ) ) ]
189
192
if self . settings . version . exact_version ( ) . is_none ( ) {
190
193
let version = get_version ( & self . settings . releases_url , & self . settings . version ) . await ?;
191
194
self . settings . version = version. exact_version_req ( ) ?;
192
195
self . settings . installation_dir =
193
196
self . settings . installation_dir . join ( version. to_string ( ) ) ;
194
197
}
198
+ #[ cfg( feature = "bundled" ) ]
199
+ if self . settings . version . exact_version ( ) . is_none ( ) {
200
+ panic ! (
201
+ "Bundled version should always be set to an exact version e.g. \" =15.4.1\" , got - {:?}" ,
202
+ self . settings. version
203
+ ) ;
204
+ }
195
205
196
206
if self . settings . installation_dir . exists ( ) {
197
207
debug ! ( "Installation directory already exists" ) ;
@@ -202,17 +212,19 @@ impl PostgreSQL {
202
212
203
213
#[ cfg( feature = "bundled" ) ]
204
214
// If the requested version is the same as the version of the bundled archive, use the bundled
205
- // archive. This avoids downloading the archive in environments where internet access is
206
- // restricted or undesirable.
215
+ // archive. Otherwise don't download the archive, because user expects the bundled archive to be used not the one from internet.
207
216
let ( version, bytes) = if * crate :: settings:: ARCHIVE_VERSION == self . settings . version {
208
217
debug ! ( "Using bundled installation archive" ) ;
209
218
(
210
219
self . settings . version . clone ( ) ,
211
220
crate :: settings:: ARCHIVE . to_vec ( ) ,
212
221
)
213
222
} else {
214
- let ( version, bytes) = get_archive ( url, & self . settings . version ) . await ?;
215
- ( version. exact_version_req ( ) ?, bytes)
223
+ panic ! (
224
+ "Bundled version \n \" {:?}\" , settings version - \" {:?}\" " ,
225
+ * crate :: settings:: ARCHIVE_VERSION ,
226
+ self . settings. version
227
+ ) ;
216
228
} ;
217
229
218
230
#[ cfg( not( feature = "bundled" ) ) ]
0 commit comments