More debug lines, and use the default config.events_dir path when not specified otherwise

This commit is contained in:
Isaac Connor 2015-12-15 11:17:32 -05:00
parent d7568180fe
commit 1151fe39ab
1 changed files with 7 additions and 1 deletions

View File

@ -29,7 +29,10 @@
Storage::Storage() { Storage::Storage() {
id = name[0] = path[0] = 0; Warning("Instantiating default Storage Object. Should not happen.");
id = 0;
strcpy(name, "Default");
strncpy(path, config.dir_events, sizeof(path) );
} }
Storage::Storage( MYSQL_ROW &dbrow ) { Storage::Storage( MYSQL_ROW &dbrow ) {
@ -41,10 +44,12 @@ Storage::Storage( MYSQL_ROW &dbrow ) {
/* If a zero or invalid p_id is passed, then the old default path will be assumed. */ /* 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 ) {
id = 0;
if ( 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 );
Debug(1,"Loading Storage for %d using %s", p_id, sql );
MYSQL_ROW dbrow = zmDbFetchOne( sql ); MYSQL_ROW dbrow = zmDbFetchOne( sql );
if ( ! dbrow ) { if ( ! dbrow ) {
Error( "Unable to load storage area for id %d: %s", p_id, mysql_error( &dbconn ) ); Error( "Unable to load storage area for id %d: %s", p_id, mysql_error( &dbconn ) );
@ -57,6 +62,7 @@ Storage::Storage( unsigned int p_id ) {
} }
} }
if ( ! id ) { if ( ! id ) {
Warning("No id passed to Storage constructor. Using default path %s instead", config.dir_events );
strcpy(name, "Default"); strcpy(name, "Default");
strncpy(path, config.dir_events, sizeof(path) ); strncpy(path, config.dir_events, sizeof(path) );
} }