make loading a null or invalid storage area not be fatal, but use the default path
This commit is contained in:
parent
a196906345
commit
6aadd7330a
|
@ -39,21 +39,28 @@ Storage::Storage( MYSQL_ROW &dbrow ) {
|
||||||
strncpy( path, dbrow[index++], sizeof(path) );
|
strncpy( path, dbrow[index++], sizeof(path) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If a zero or invalid p_id is passed, then the old default path will be assumed. */
|
||||||
Storage::Storage( unsigned int p_id ) {
|
Storage::Storage( unsigned int p_id ) {
|
||||||
|
|
||||||
|
if ( p_id ) {
|
||||||
char sql[ZM_SQL_SML_BUFSIZ];
|
char sql[ZM_SQL_SML_BUFSIZ];
|
||||||
snprintf( sql, sizeof(sql), "SELECT Id, Name, Path from Storage WHERE Id=%d", p_id );
|
snprintf( sql, sizeof(sql), "SELECT Id, Name, Path from Storage WHERE Id=%d", p_id );
|
||||||
MYSQL_ROW dbrow = zmDbFetchOne( sql );
|
MYSQL_ROW dbrow = zmDbFetchOne( sql );
|
||||||
if ( ! dbrow ) {
|
if ( ! dbrow ) {
|
||||||
Error( "Can't use query result: %s", mysql_error( &dbconn ) );
|
Error( "Unable to load storage area for id %d: %s", p_id, mysql_error( &dbconn ) );
|
||||||
exit( mysql_errno( &dbconn ) );
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
id = atoi( dbrow[index++] );
|
id = atoi( dbrow[index++] );
|
||||||
strncpy( name, dbrow[index++], sizeof(name) );
|
strncpy( name, dbrow[index++], sizeof(name) );
|
||||||
strncpy( path, dbrow[index++], sizeof(path) );
|
strncpy( path, dbrow[index++], sizeof(path) );
|
||||||
Info( "Loaded Storage area '%s'", this->getName() );
|
Info( "Loaded Storage area '%s'", this->getName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! id ) {
|
||||||
|
strcpy(name, "Default");
|
||||||
|
strncpy(path, config.dir_events, sizeof(path) );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::~Storage() {
|
Storage::~Storage() {
|
||||||
|
|
Loading…
Reference in New Issue