Ticket #2958: mythmusic_cleanup.diff
| File mythmusic_cleanup.diff, 1.8 KB (added by , 20 years ago) |
|---|
-
mythmusic/mythmusic/main.cpp
245 245 } 246 246 } 247 247 248 void cleanDB() 249 { 250 MythProgressDialog *clean_progress; 251 clean_progress = new MythProgressDialog( 252 QObject::tr("Cleaning music database"), 3); 253 254 int counter = 0; 255 256 MSqlQuery query(MSqlQuery::InitCon()); 257 query.exec("DELETE FROM music_genres " 258 "WHERE genre_id not in " 259 "(SELECT DISTINCT genre_id FROM music_songs);"); 260 clean_progress->setProgress(++counter); 261 262 query.exec("DELETE FROM music_albums " 263 "WHERE album_id not in " 264 "(SELECT DISTINCT album_id FROM music_songs);"); 265 clean_progress->setProgress(++counter); 266 267 query.exec("DELETE FROM music_artists " 268 "WHERE artist_id not in " 269 "(SELECT DISTINCT artist_id FROM music_songs);"); 270 clean_progress->setProgress(++counter); 271 272 clean_progress->Close(); 273 delete clean_progress; 274 } 275 248 276 void SearchDir(QString &directory) 249 277 { 250 278 MusicLoadedMap music_files; … … 313 341 3) UpdateFileInDB, same as 1. 314 342 */ 315 343 344 bool files_removed = false; 316 345 counter = 0; 317 346 for (iter = music_files.begin(); iter != music_files.end(); iter++) 318 347 { 319 348 if (*iter == kFileSystem) 320 349 AddFileToDB(iter.key()); 321 350 else if (*iter == kDatabase) 351 { 322 352 RemoveFileFromDB(directory, iter.key ()); 353 files_removed = true; 354 } 323 355 else if (*iter == kNeedUpdate) 324 356 UpdateFileInDB(iter.key()); 325 357 326 358 file_checking->setProgress(++counter); 327 359 } 360 328 361 file_checking->Close(); 329 362 delete file_checking; 363 364 if(files_removed) 365 cleanDB(); 330 366 } 331 367 332 368 void startPlayback(PlaylistsContainer *all_playlists, AllMusic *all_music)
