Commit 052a024d authored by Claes Sjofors's avatar Claes Sjofors

Dbs files for classvolumes always loaded before other volumes

parent 33f46c23
...@@ -529,7 +529,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -529,7 +529,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
char fname[200]; char fname[200];
char vname[200]; char vname[200];
char line[200]; char line[200];
int i; int i, j;
pwr_tVid vid; pwr_tVid vid;
pwr_tStatus sts; pwr_tStatus sts;
wb_vrepdbs *vrep; wb_vrepdbs *vrep;
...@@ -538,262 +538,271 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -538,262 +538,271 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
strcpy( fname, load_cNameVolumeList); strcpy( fname, load_cNameVolumeList);
dcli_translate_filename( fname, fname); dcli_translate_filename( fname, fname);
ifstream fpm( fname, ios::in); // Load classvolumes first (j == 0) and then other volumes (j == 1)
if ( !fpm) { for ( j = 0; j < 2; j++) {
*status = LDH__PROJCONFIG; ifstream fpm( fname, ios::in);
if ( !fpm) {
// Load directory volume *status = LDH__PROJCONFIG;
strcpy( vname, "$pwrp_db/directory.db");
dcli_translate_filename( vname, vname);
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name("directory");
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Directory database opened", vname);
}
return;
}
while ( fpm.getline( line, sizeof(line))) {
char vol_array[7][80];
int nr;
if ( line[0] == '#') // Load directory volume
continue; strcpy( vname, "$pwrp_db/directory.db");
dcli_translate_filename( vname, vname);
nr = dcli_parse( line, " ", "", (char *)vol_array, sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
sizeof(vol_array)/sizeof(vol_array[0]), dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
sizeof(vol_array[0]), 0); if ( ODD(sts)) {
if ( nr > 6) wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
cout << "Syntax error in file: " << fname << endl; vrepdb->name("directory");
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Directory database opened", vname);
}
cdh_StringToVolumeId( vol_array[1], &vid); return;
}
if ( cdh_NoCaseStrcmp( vol_array[2], "ExternVolume") == 0) { while ( fpm.getline( line, sizeof(line))) {
if ( nr != 6) char vol_array[7][80];
cout << "Syntax error in file: " << fname << endl; int nr;
// Load extern volume for this volume if ( line[0] == '#')
cdh_ToLower( vol_array[0], vol_array[0]); continue;
try { nr = dcli_parse( line, " ", "", (char *)vol_array,
wb_vrepext *vrepext = new wb_vrepext( this, vid, vol_array[0], vol_array[4]); sizeof(vol_array)/sizeof(vol_array[0]),
addExtern( &sts, vrepext); sizeof(vol_array[0]), 0);
MsgWindow::message( 'O', "Volume loaded", vname); if ( nr > 6)
vol_cnt++;
}
catch ( wb_error& e) {
MsgWindow::message( 'E', "Unable to open volume", vname, e.what().c_str());
}
}
else if ( cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0 ||
cdh_NoCaseStrcmp( vol_array[2], "DetachedClassVolume") == 0 ||
strcmp( vol_array[3], "load") == 0) {
if ( nr < 4)
cout << "Syntax error in file: " << fname << endl; cout << "Syntax error in file: " << fname << endl;
// Load dbs for this volume cdh_StringToVolumeId( vol_array[1], &vid);
cdh_ToLower( vol_array[0], vol_array[0]);
if ( strcmp( vol_array[3], "cnf") == 0) { if ( cdh_NoCaseStrcmp( vol_array[2], "ExternVolume") == 0) {
// Configured in this project, load from pwrp_load if ( j == 1) {
strcpy( vname, "$pwrp_load/"); if ( nr != 6)
strcat( vname, vol_array[0]); cout << "Syntax error in file: " << fname << endl;
strcat( vname, ".dbs");
dcli_translate_filename( vname, vname);
// Load...
try {
vrep = new wb_vrepdbs( this, vname);
vrep->load();
addDbs( &sts, vrep);
MsgWindow::message( 'O', "Volume loaded from snapshot file", vname);
vol_cnt++;
}
catch ( wb_error& e) {
if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
}
if ( nr >= 5 && vol_array[4][0] == '1') {
// BerkelyDb class volume
strcpy( vname, "$pwrp_db/");
strcat( vname, vol_array[0]);
strcat( vname, ".db");
dcli_translate_filename( vname, vname);
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname); // Load extern volume for this volume
cdh_ToLower( vol_array[0], vol_array[0]);
wb_vrepced *vrepced = new wb_vrepced( this, vrepdb); try {
vrepced->name(vol_array[0]); wb_vrepext *vrepext = new wb_vrepext( this, vid, vol_array[0], vol_array[4]);
addDb( &sts, vrepced); addExtern( &sts, vrepext);
MsgWindow::message( 'I', "Classvolume Database opened", vname); MsgWindow::message( 'O', "Volume loaded", vname);
vol_cnt++; vol_cnt++;
}
catch ( wb_error& e) {
MsgWindow::message( 'E', "Unable to open volume", vname, e.what().c_str());
}
} }
} }
else { else if ( cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0 ||
// Imported loadfile cdh_NoCaseStrcmp( vol_array[2], "DetachedClassVolume") == 0 ||
bool found = false; strcmp( vol_array[3], "load") == 0) {
for ( i = 0; i < m_dir_cnt; i++) { if ( j == 0) {
strcpy( vname, m_dir_list[i]); if ( nr < 4)
strcat( vname, vol_array[0]); cout << "Syntax error in file: " << fname << endl;
strcat( vname, ".dbs");
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT); // Load dbs for this volume
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END); cdh_ToLower( vol_array[0], vol_array[0]);
if ( ODD(sts)) {
// Load... if ( strcmp( vol_array[3], "cnf") == 0) {
found = true; // Configured in this project, load from pwrp_load
try { strcpy( vname, "$pwrp_load/");
vrep = new wb_vrepdbs( this, vname); strcat( vname, vol_array[0]);
vrep->load(); strcat( vname, ".dbs");
// vrep->name( vol_array[0]); dcli_translate_filename( vname, vname);
addDbs( &sts, vrep);
MsgWindow::message( 'O', "Volume loaded from snapshot file", vname); // Load...
} try {
catch ( wb_error& e) { vrep = new wb_vrepdbs( this, vname);
if ( m_options & ldh_mWbOption_IgnoreDLoadError) vrep->load();
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname); addDbs( &sts, vrep);
else MsgWindow::message( 'O', "Volume loaded from snapshot file", vname);
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str()); vol_cnt++;
} }
break; catch ( wb_error& e) {
}
}
if ( !found)
MsgWindow::message( 'E', "Volume snapshotfile not found", vname);
}
}
else {
// Load db for this volume
char uname[80];
if ( nr < 4)
cout << "Syntax error in file: " << fname << endl;
if ( db) {
// If db is specified, load only specified db, load as dbs instead
if ( cdh_NoCaseStrcmp( vol_array[0], db) != 0) {
cdh_ToLower( vol_array[0], vol_array[0]);
strcpy( vname, "$pwrp_load/");
strcat( vname, vol_array[0]);
strcat( vname, ".dbs");
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) {
// Load...
try {
vrep = new wb_vrepdbs( this, found_file);
vrep->load();
// vrep->name( vol_array[0]);
addDbs( &sts, vrep);
MsgWindow::message( 'O', "Volume loaded from snapshot file", vname);
}
catch ( wb_error& e) {
if ( m_options & ldh_mWbOption_IgnoreDLoadError) if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname); MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str()); MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
} }
} if ( nr >= 5 && vol_array[4][0] == '1') {
continue; // BerkelyDb class volume
} strcpy( vname, "$pwrp_db/");
} strcat( vname, vol_array[0]);
strcpy( vname, "$pwrp_db/"); strcat( vname, ".db");
strcat( vname, vol_array[0]); dcli_translate_filename( vname, vname);
cdh_ToLower( vname, vname);
if ( nr >= 5 && vol_array[4][0] == '1') wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
strcat( vname, ".dbms");
else wb_vrepced *vrepced = new wb_vrepced( this, vrepdb);
strcat( vname, ".db"); vrepced->name(vol_array[0]);
dcli_translate_filename( vname, vname); addDb( &sts, vrepced);
MsgWindow::message( 'I', "Classvolume Database opened", vname);
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT); vol_cnt++;
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END); }
if ( EVEN(sts)) { }
MsgWindow::message( 'E', "Database not found", vname); else {
// Imported loadfile
bool found = false;
for ( i = 0; i < m_dir_cnt; i++) {
strcpy( vname, m_dir_list[i]);
strcat( vname, vol_array[0]);
strcat( vname, ".dbs");
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) {
// Load...
found = true;
try {
vrep = new wb_vrepdbs( this, vname);
vrep->load();
// vrep->name( vol_array[0]);
addDbs( &sts, vrep);
MsgWindow::message( 'O', "Volume loaded from snapshot file", vname);
}
catch ( wb_error& e) {
if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
}
break;
}
}
if ( !found)
MsgWindow::message( 'E', "Volume snapshotfile not found", vname);
}
}
} }
else { else {
int open_loadfile = 0; if ( j == 1) {
// Load db for this volume
if ( wb_dblock::is_locked(vname, uname)) { char uname[80];
char msg[120];
if ( nr < 4)
sprintf( msg, "Database %s is locked by user %s", vol_array[0], uname); cout << "Syntax error in file: " << fname << endl;
MsgWindow::message( 'E', msg, msgw_ePop_No);
if ( db) {
if ( ! MsgWindow::has_window()) // If db is specified, load only specified db, load as dbs instead
exit(0); if ( cdh_NoCaseStrcmp( vol_array[0], db) != 0) {
cdh_ToLower( vol_array[0], vol_array[0]);
CoWow *wow = MsgWindow::get_wow(); strcpy( vname, "$pwrp_load/");
int res = wow->CreateModalDialog( "Database Locked", msg, "Exit", "Enter loadfile", "Remove lock", strcat( vname, vol_array[0]);
"$pwr_exe/wtt_padlock.png"); strcat( vname, ".dbs");
switch( res) { sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
case wow_eModalDialogReturn_Button1: dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
case wow_eModalDialogReturn_Deleted: if ( ODD(sts)) {
exit(0); // Load...
case wow_eModalDialogReturn_Button3: try {
// Remove lock vrep = new wb_vrepdbs( this, found_file);
wb_dblock::dbunlock(vname); vrep->load();
break; // vrep->name( vol_array[0]);
case wow_eModalDialogReturn_NYI: addDbs( &sts, vrep);
case wow_eModalDialogReturn_Button2: MsgWindow::message( 'O', "Volume loaded from snapshot file", vname);
// Enter loadfile }
open_loadfile = 1; catch ( wb_error& e) {
break; if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
}
}
continue;
}
} }
strcpy( vname, "$pwrp_db/");
}
if ( open_loadfile) {
// Open dbs
cdh_ToLower( vol_array[0], vol_array[0]);
strcpy( vname, "$pwrp_load/");
strcat( vname, vol_array[0]); strcat( vname, vol_array[0]);
strcat( vname, ".dbs"); cdh_ToLower( vname, vname);
if ( nr >= 5 && vol_array[4][0] == '1')
strcat( vname, ".dbms");
else
strcat( vname, ".db");
dcli_translate_filename( vname, vname); dcli_translate_filename( vname, vname);
try { sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
vrep = new wb_vrepdbs( this, vname); dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
vrep->load(); if ( EVEN(sts)) {
addDbs( &sts, vrep); MsgWindow::message( 'E', "Database not found", vname);
MsgWindow::message( 'I', "Volume loaded from snapshot file", vname);
vol_cnt++;
}
catch ( wb_error& e) {
if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
} }
} else {
else { int open_loadfile = 0;
// Open db
if ( nr >= 5 && vol_array[4][0] == '1') { if ( wb_dblock::is_locked(vname, uname)) {
char msg[120];
sprintf( msg, "Database %s is locked by user %s", vol_array[0], uname);
MsgWindow::message( 'E', msg, msgw_ePop_No);
if ( ! MsgWindow::has_window())
exit(0);
CoWow *wow = MsgWindow::get_wow();
int res = wow->CreateModalDialog( "Database Locked", msg, "Exit", "Enter loadfile", "Remove lock",
"$pwr_exe/wtt_padlock.png");
switch( res) {
case wow_eModalDialogReturn_Button1:
case wow_eModalDialogReturn_Deleted:
exit(0);
case wow_eModalDialogReturn_Button3:
// Remove lock
wb_dblock::dbunlock(vname);
break;
case wow_eModalDialogReturn_NYI:
case wow_eModalDialogReturn_Button2:
// Enter loadfile
open_loadfile = 1;
break;
}
}
if ( open_loadfile) {
// Open dbs
cdh_ToLower( vol_array[0], vol_array[0]);
strcpy( vname, "$pwrp_load/");
strcat( vname, vol_array[0]);
strcat( vname, ".dbs");
dcli_translate_filename( vname, vname);
try {
vrep = new wb_vrepdbs( this, vname);
vrep->load();
addDbs( &sts, vrep);
MsgWindow::message( 'I', "Volume loaded from snapshot file", vname);
vol_cnt++;
}
catch ( wb_error& e) {
if ( m_options & ldh_mWbOption_IgnoreDLoadError)
MsgWindow::message( 'I', "Unable to open volume snapshot file", vname);
else
MsgWindow::message( 'E', "Unable to open volume snapshot file", vname, e.what().c_str());
}
}
else {
// Open db
if ( nr >= 5 && vol_array[4][0] == '1') {
#if defined PWRE_CONF_MYSQL #if defined PWRE_CONF_MYSQL
wb_vrepdbms *vrepdbms = new wb_vrepdbms( this, vname); wb_vrepdbms *vrepdbms = new wb_vrepdbms( this, vname);
vrepdbms->name(vol_array[0]); vrepdbms->name(vol_array[0]);
addDb( &sts, vrepdbms); addDb( &sts, vrepdbms);
MsgWindow::message( 'I', "Database opened", vname); MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++; vol_cnt++;
#endif #endif
} }
else { else {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname); wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]); vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb); addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname); MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++; vol_cnt++;
}
}
} }
} }
} }
} }
fpm.close();
} }
fpm.close();
// Identify dbs that also is loaded as db // Identify dbs that also is loaded as db
vrep_iterator itdbs, itdb; vrep_iterator itdbs, itdb;
...@@ -801,7 +810,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -801,7 +810,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
for ( itdbs = m_vrepdbs.begin(); itdbs != m_vrepdbs.end(); itdbs++) { for ( itdbs = m_vrepdbs.begin(); itdbs != m_vrepdbs.end(); itdbs++) {
for ( itdb = m_vrepdb.begin(); itdb != m_vrepdb.end(); itdb++) { for ( itdb = m_vrepdb.begin(); itdb != m_vrepdb.end(); itdb++) {
if ( itdbs->first == itdb->first) if ( itdbs->first == itdb->first)
itdbs->second->setDuplicateDb( true); itdbs->second->setDuplicateDb( true);
} }
} }
...@@ -850,6 +859,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -850,6 +859,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
addDb( &sts, vrepdb); addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname); MsgWindow::message( 'I', "Database opened", vname);
} }
if ( !vol_cnt) if ( !vol_cnt)
*status = LDH__PROJCONFIG; *status = LDH__PROJCONFIG;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment