functions.cpp: slight reformat, better refreshSelectDB

Turns out that printing 100 wasn't required to hide progress window,
that is a part of ProgressBar destructor.

refreshSelectDB now shows "Updating *show* in database" so it won't hang
for a few seconds at 100% after renaming
This commit is contained in:
zvon 2020-04-13 22:38:57 +02:00
parent 4e52a98eae
commit 14ca3416d2

View File

@ -507,13 +507,8 @@ void addToDB( const string &show, const string &path, const string &language,
ProgressBar p( progress_ptr ); ProgressBar p( progress_ptr );
#endif #endif
if( seasons.size() == 0 ) { if( seasons.size() == 0 )
#ifdef GUI
// hide progress window
p.print( 100 );
#endif
return; return;
}
p.print( _( RENAMING ) ); p.print( _( RENAMING ) );
p.print( 0 ); p.print( 0 );
@ -614,13 +609,8 @@ void refreshDB( bool linux, void *progress_ptr ) {
ProgressBar p( progress_ptr ); ProgressBar p( progress_ptr );
#endif // GUI #endif // GUI
if( shows.size() == 0 ) { if( shows.size() == 0 )
#ifdef GUI
// hide progress window
p.print(100);
#endif
return; return;
}
for ( auto &show : shows ) { for ( auto &show : shows ) {
if ( FSLib::exists( show[TEXT( "PATH" )] ) ) { if ( FSLib::exists( show[TEXT( "PATH" )] ) ) {
@ -706,13 +696,8 @@ void updateDB( bool linux, void *progress_ptr ) {
ProgressBar p( progress_ptr ); ProgressBar p( progress_ptr );
#endif #endif
if( shows.size() == 0 ) { if( shows.size() == 0 )
#ifdef GUI
// hide progress window
p.print( 100 );
#endif
return; return;
}
p.print( _( UPDATING_DB ) ); p.print( _( UPDATING_DB ) );
@ -726,7 +711,7 @@ void updateDB( bool linux, void *progress_ptr ) {
#ifndef GUI #ifndef GUI
cleanUpLine(); cleanUpLine();
#endif #endif
p.print( _( UPDATING ) + string( ' ', 1 ) + show[TEXT( "SHOW" )] ); p.print( _( UPDATING ) + string( 1, ' ' ) + show[TEXT( "SHOW" )] );
std::unordered_set< string > episodes; std::unordered_set< string > episodes;
db.exec( TEXT( "SELECT PATH FROM EPISODES WHERE SHOWID == " ) + db.exec( TEXT( "SELECT PATH FROM EPISODES WHERE SHOWID == " ) +
@ -811,13 +796,8 @@ void cleanDB( void *progress_ptr ) {
ProgressBar p( progress_ptr ); ProgressBar p( progress_ptr );
#endif // GUI #endif // GUI
if( shows.size() == 0 ) { if( shows.size() == 0 )
#ifdef GUI
// hide progress window
p.print( 100 );
#endif
return; return;
}
p.print( _( CLEANING_DB ) ); p.print( _( CLEANING_DB ) );
p.print( 0 ); p.print( 0 );
@ -966,6 +946,10 @@ void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux,
p.print( ( i * 100 ) / size ); p.print( ( i * 100 ) / size );
} }
p.print( 100 ); p.print( 100 );
p.print( _( UPDATING_IN_DB, show[TEXT( "SHOW" )].c_str() ) );
p.print( 0 );
i = 0;
for ( auto &season : seasons ) { for ( auto &season : seasons ) {
for ( auto &episode : season.second ) { for ( auto &episode : season.second ) {
db.exec( TEXT( "INSERT INTO EPISODES ( SHOWID, PATH ) " db.exec( TEXT( "INSERT INTO EPISODES ( SHOWID, PATH ) "
@ -973,6 +957,8 @@ void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux,
show[TEXT( "ID" )] + TEXT( ", '" ) + show[TEXT( "ID" )] + TEXT( ", '" ) +
sanitize( episode.second ) + TEXT( "' );" ) ); sanitize( episode.second ) + TEXT( "' );" ) );
} }
i++;
p.print( ( i * 100 ) / seasons.size() );
} }
} }
} }