@@ -19,55 +19,64 @@ execute_override(basename(__FILE__));
1919
2020// -----------------------------------------------------------------------------
2121
22+ // Database index suffix. When set (e.g., "2"), all DB-related variable lookups
23+ // use the indexed variant (e.g., VORTEX_DOWNLOAD_DB2_SOURCE instead of
24+ // VORTEX_DOWNLOAD_DB_SOURCE).
25+ $ db_index = getenv_default ('VORTEX_DB_INDEX ' , '' );
26+
2227// Database download source.
23- $ source = getenv_default (' VORTEX_DOWNLOAD_DB_SOURCE ' , 'url ' );
28+ $ source = getenv_default (... array_values ( array_unique ([ ' VORTEX_DOWNLOAD_DB ' . $ db_index . ' _SOURCE ' , ' VORTEX_DOWNLOAD_DB_SOURCE ' , 'url ' ])) );
2429
2530// Force DB download even if the cache exists.
26- $ force = getenv_default (' VORTEX_DOWNLOAD_DB_FORCE ' , '' );
31+ $ force = getenv_default (... array_values ( array_unique ([ ' VORTEX_DOWNLOAD_DB ' . $ db_index . ' _FORCE ' , ' VORTEX_DOWNLOAD_DB_FORCE ' , '' ])) );
2732
2833// Proceed with download.
29- $ proceed = getenv_default (' VORTEX_DOWNLOAD_DB_PROCEED ' , '1 ' );
34+ $ proceed = getenv_default (... array_values ( array_unique ([ ' VORTEX_DOWNLOAD_DB ' . $ db_index . ' _PROCEED ' , ' VORTEX_DOWNLOAD_DB_PROCEED ' , '1 ' ])) );
3035
3136// Database dump file name.
32- $ db_file = getenv_default (' VORTEX_DOWNLOAD_DB_FILE ' , 'VORTEX_DB_FILE ' , 'db.sql ' );
37+ $ db_file = getenv_default (... array_values ( array_unique ([ ' VORTEX_DOWNLOAD_DB ' . $ db_index . ' _FILE ' , ' VORTEX_DB ' . $ db_index . ' _FILE ' , ' VORTEX_DOWNLOAD_DB_FILE ' , 'VORTEX_DB_FILE ' , 'db.sql ' ])) );
3338
3439// Directory with database dump file.
35- $ db_dir = getenv_default (' VORTEX_DOWNLOAD_DB_DIR ' , 'VORTEX_DB_DIR ' , './.data ' );
40+ $ db_dir = getenv_default (... array_values ( array_unique ([ ' VORTEX_DOWNLOAD_DB ' . $ db_index . ' _DIR ' , ' VORTEX_DB ' . $ db_index . ' _DIR ' , ' VORTEX_DOWNLOAD_DB_DIR ' , 'VORTEX_DB_DIR ' , './.data ' ])) );
3641
3742// Semaphore file to indicate download completion.
3843$ semaphore = getenv_default ('VORTEX_DOWNLOAD_DB_SEMAPHORE ' , '' );
3944
4045// -----------------------------------------------------------------------------
4146
42- info ('Started database download. ' );
47+ info ('Started database%s download. ' , $ db_index !== '' ? ' ' . $ db_index : ' ' );
4348
4449if ($ proceed !== '1 ' ) {
4550 pass ('Skipping database download as VORTEX_DOWNLOAD_DB_PROCEED is not set to 1. ' );
4651 quit (0 );
4752}
4853
49- // Check for existing dump files.
50- $ db_file_basename = pathinfo ($ db_file , PATHINFO_FILENAME );
51- $ found_db = '' ;
52- if (is_dir ($ db_dir )) {
53- $ files = glob ($ db_dir . '/ ' . $ db_file_basename . '.{sql,tar} ' , GLOB_BRACE );
54- if ($ files !== FALSE && count ($ files ) > 0 ) {
55- $ found_db = implode ("\n" , $ files );
54+ // Skip file existence check for container_registry source as the database is
55+ // stored as a Docker image, not a file.
56+ if ($ source !== 'container_registry ' ) {
57+ // Check for existing dump files.
58+ $ db_file_basename = pathinfo ($ db_file , PATHINFO_FILENAME );
59+ $ found_db = '' ;
60+ if (is_dir ($ db_dir )) {
61+ $ files = glob ($ db_dir . '/ ' . $ db_file_basename . '.{sql,tar} ' , GLOB_BRACE );
62+ if ($ files !== FALSE && count ($ files ) > 0 ) {
63+ $ found_db = implode ("\n" , $ files );
64+ }
5665 }
57- }
5866
59- if ($ found_db !== '' ) {
60- note ('Found existing database dump file(s). ' );
61- passthru ('ls -Alh ' . escapeshellarg ($ db_dir ) . ' 2>/dev/null || true ' );
67+ if ($ found_db !== '' ) {
68+ note ('Found existing database dump file(s). ' );
69+ passthru ('ls -Alh ' . escapeshellarg ($ db_dir ) . ' 2>/dev/null || true ' );
6270
63- if ($ force !== '1 ' ) {
64- note ('Using existing database dump file(s). ' );
65- note ('Download will not proceed. ' );
66- note ('Remove existing database file or set VORTEX_DOWNLOAD_DB_FORCE value to 1 to force download. ' );
67- quit (0 );
68- }
71+ if ($ force !== '1 ' ) {
72+ note ('Using existing database dump file(s). ' );
73+ note ('Download will not proceed. ' );
74+ note ('Remove existing database file or set VORTEX_DOWNLOAD_DB_FORCE value to 1 to force download. ' );
75+ quit (0 );
76+ }
6977
70- note ('Will download a fresh copy of the database. ' );
78+ note ('Will download a fresh copy of the database. ' );
79+ }
7180}
7281
7382$ sources = [
@@ -92,4 +101,4 @@ if ($semaphore !== '') {
92101 touch ($ semaphore );
93102}
94103
95- pass ('Finished database download. ' );
104+ pass ('Finished database%s download. ' , $ db_index !== '' ? ' ' . $ db_index : ' ' );
0 commit comments