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)
char fname[200];
char vname[200];
char line[200];
int i;
int i, j;
pwr_tVid vid;
pwr_tStatus sts;
wb_vrepdbs *vrep;
......@@ -538,262 +538,271 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
strcpy( fname, load_cNameVolumeList);
dcli_translate_filename( fname, fname);
ifstream fpm( fname, ios::in);
if ( !fpm) {
*status = LDH__PROJCONFIG;
// Load directory volume
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;
// Load classvolumes first (j == 0) and then other volumes (j == 1)
for ( j = 0; j < 2; j++) {
ifstream fpm( fname, ios::in);
if ( !fpm) {
*status = LDH__PROJCONFIG;
if ( line[0] == '#')
continue;
// Load directory volume
strcpy( vname, "$pwrp_db/directory.db");
dcli_translate_filename( vname, vname);
nr = dcli_parse( line, " ", "", (char *)vol_array,
sizeof(vol_array)/sizeof(vol_array[0]),
sizeof(vol_array[0]), 0);
if ( nr > 6)
cout << "Syntax error in file: " << fname << endl;
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);
}
cdh_StringToVolumeId( vol_array[1], &vid);
return;
}
if ( cdh_NoCaseStrcmp( vol_array[2], "ExternVolume") == 0) {
if ( nr != 6)
cout << "Syntax error in file: " << fname << endl;
while ( fpm.getline( line, sizeof(line))) {
char vol_array[7][80];
int nr;
// Load extern volume for this volume
cdh_ToLower( vol_array[0], vol_array[0]);
if ( line[0] == '#')
continue;
try {
wb_vrepext *vrepext = new wb_vrepext( this, vid, vol_array[0], vol_array[4]);
addExtern( &sts, vrepext);
MsgWindow::message( 'O', "Volume loaded", vname);
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)
nr = dcli_parse( line, " ", "", (char *)vol_array,
sizeof(vol_array)/sizeof(vol_array[0]),
sizeof(vol_array[0]), 0);
if ( nr > 6)
cout << "Syntax error in file: " << fname << endl;
// Load dbs for this volume
cdh_ToLower( vol_array[0], vol_array[0]);
cdh_StringToVolumeId( vol_array[1], &vid);
if ( strcmp( vol_array[3], "cnf") == 0) {
// Configured in this project, load from pwrp_load
strcpy( vname, "$pwrp_load/");
strcat( vname, vol_array[0]);
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);
if ( cdh_NoCaseStrcmp( vol_array[2], "ExternVolume") == 0) {
if ( j == 1) {
if ( nr != 6)
cout << "Syntax error in file: " << fname << endl;
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);
vrepced->name(vol_array[0]);
addDb( &sts, vrepced);
MsgWindow::message( 'I', "Classvolume Database opened", vname);
vol_cnt++;
try {
wb_vrepext *vrepext = new wb_vrepext( this, vid, vol_array[0], vol_array[4]);
addExtern( &sts, vrepext);
MsgWindow::message( 'O', "Volume loaded", vname);
vol_cnt++;
}
catch ( wb_error& e) {
MsgWindow::message( 'E', "Unable to open volume", vname, e.what().c_str());
}
}
}
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 {
// 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) {
else if ( cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0 ||
cdh_NoCaseStrcmp( vol_array[2], "DetachedClassVolume") == 0 ||
strcmp( vol_array[3], "load") == 0) {
if ( j == 0) {
if ( nr < 4)
cout << "Syntax error in file: " << fname << endl;
// Load dbs for this volume
cdh_ToLower( vol_array[0], vol_array[0]);
if ( strcmp( vol_array[3], "cnf") == 0) {
// Configured in this project, load from pwrp_load
strcpy( vname, "$pwrp_load/");
strcat( vname, vol_array[0]);
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());
}
}
continue;
}
}
strcpy( vname, "$pwrp_db/");
strcat( vname, vol_array[0]);
cdh_ToLower( vname, vname);
if ( nr >= 5 && vol_array[4][0] == '1')
strcat( vname, ".dbms");
else
strcat( vname, ".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 ( EVEN(sts)) {
MsgWindow::message( 'E', "Database not found", vname);
}
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);
wb_vrepced *vrepced = new wb_vrepced( this, vrepdb);
vrepced->name(vol_array[0]);
addDb( &sts, vrepced);
MsgWindow::message( 'I', "Classvolume Database opened", vname);
vol_cnt++;
}
}
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 {
int open_loadfile = 0;
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 ( j == 1) {
// 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)
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;
}
}
}
if ( open_loadfile) {
// Open dbs
cdh_ToLower( vol_array[0], vol_array[0]);
strcpy( vname, "$pwrp_load/");
strcpy( vname, "$pwrp_db/");
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);
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());
sts = dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( vname, found_file, DCLI_DIR_SEARCH_END);
if ( EVEN(sts)) {
MsgWindow::message( 'E', "Database not found", vname);
}
}
else {
// Open db
if ( nr >= 5 && vol_array[4][0] == '1') {
else {
int open_loadfile = 0;
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
wb_vrepdbms *vrepdbms = new wb_vrepdbms( this, vname);
vrepdbms->name(vol_array[0]);
addDb( &sts, vrepdbms);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
wb_vrepdbms *vrepdbms = new wb_vrepdbms( this, vname);
vrepdbms->name(vol_array[0]);
addDb( &sts, vrepdbms);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
#endif
}
else {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
}
else {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
}
}
}
}
}
}
fpm.close();
}
fpm.close();
// Identify dbs that also is loaded as db
vrep_iterator itdbs, itdb;
......@@ -801,7 +810,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
for ( itdbs = m_vrepdbs.begin(); itdbs != m_vrepdbs.end(); itdbs++) {
for ( itdb = m_vrepdb.begin(); itdb != m_vrepdb.end(); itdb++) {
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)
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
}
if ( !vol_cnt)
*status = LDH__PROJCONFIG;
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