From 14ca3416d2aae4d1e9d62b43172b9a0422d0aee7 Mon Sep 17 00:00:00 2001 From: zvon Date: Mon, 13 Apr 2020 22:38:57 +0200 Subject: [PATCH] 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 --- functions.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/functions.cpp b/functions.cpp index 6907021..d64410c 100644 --- a/functions.cpp +++ b/functions.cpp @@ -507,13 +507,8 @@ void addToDB( const string &show, const string &path, const string &language, ProgressBar p( progress_ptr ); #endif - if( seasons.size() == 0 ) { -#ifdef GUI - // hide progress window - p.print( 100 ); -#endif + if( seasons.size() == 0 ) return; - } p.print( _( RENAMING ) ); p.print( 0 ); @@ -614,13 +609,8 @@ void refreshDB( bool linux, void *progress_ptr ) { ProgressBar p( progress_ptr ); #endif // GUI - if( shows.size() == 0 ) { -#ifdef GUI - // hide progress window - p.print(100); -#endif + if( shows.size() == 0 ) return; - } for ( auto &show : shows ) { if ( FSLib::exists( show[TEXT( "PATH" )] ) ) { @@ -706,13 +696,8 @@ void updateDB( bool linux, void *progress_ptr ) { ProgressBar p( progress_ptr ); #endif - if( shows.size() == 0 ) { -#ifdef GUI - // hide progress window - p.print( 100 ); -#endif + if( shows.size() == 0 ) return; - } p.print( _( UPDATING_DB ) ); @@ -726,7 +711,7 @@ void updateDB( bool linux, void *progress_ptr ) { #ifndef GUI cleanUpLine(); #endif - p.print( _( UPDATING ) + string( ' ', 1 ) + show[TEXT( "SHOW" )] ); + p.print( _( UPDATING ) + string( 1, ' ' ) + show[TEXT( "SHOW" )] ); std::unordered_set< string > episodes; db.exec( TEXT( "SELECT PATH FROM EPISODES WHERE SHOWID == " ) + @@ -811,13 +796,8 @@ void cleanDB( void *progress_ptr ) { ProgressBar p( progress_ptr ); #endif // GUI - if( shows.size() == 0 ) { -#ifdef GUI - // hide progress window - p.print( 100 ); -#endif + if( shows.size() == 0 ) return; - } p.print( _( CLEANING_DB ) ); p.print( 0 ); @@ -966,6 +946,10 @@ void refreshSelectDB( std::unordered_set< size_t > indexes, bool linux, p.print( ( i * 100 ) / size ); } p.print( 100 ); + + p.print( _( UPDATING_IN_DB, show[TEXT( "SHOW" )].c_str() ) ); + p.print( 0 ); + i = 0; for ( auto &season : seasons ) { for ( auto &episode : season.second ) { 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( ", '" ) + sanitize( episode.second ) + TEXT( "' );" ) ); } + i++; + p.print( ( i * 100 ) / seasons.size() ); } } }