Index: Slim/Music/MusicFolderScan.pm =================================================================== --- Slim/Music/MusicFolderScan.pm (revision 3952) +++ Slim/Music/MusicFolderScan.pm (working copy) @@ -46,8 +46,10 @@ } if ($stillScanning) { - $::d_info && msg("Scan already in progress. Aborting\n"); + $::d_info && msg("Scan already in progress. Restarting\n"); + $stillScanning = 0; Slim::Utils::Scan::stopAddToList(\@dummylist); + @dummylist = (); } $stillScanning = 1; @@ -68,6 +70,9 @@ } sub doneScanning { + #If scan aborted, $stillScanning will already be false. + return unless $stillScanning; + $::d_info && msg("finished background scan of music folder.\n"); $stillScanning = 0; Index: Slim/Music/PlaylistFolderScan.pm =================================================================== --- Slim/Music/PlaylistFolderScan.pm (revision 3952) +++ Slim/Music/PlaylistFolderScan.pm (working copy) @@ -42,9 +42,11 @@ } if ($stillScanning) { - $::d_info && msg("Scan already in progress. Aborting\n"); + $::d_info && msg("Scan already in progress. Restarting\n"); + $stillScanning = 0; Slim::Utils::Scan::stopAddToList(\@dummylist); - } + @dummylist = (); + } $stillScanning = 1; @@ -53,6 +55,9 @@ } sub doneScanning { + #If scan aborted, $stillScanning will already be false. + return unless $stillScanning; + $::d_info && msg("finished background scan of playlist folder.\n"); $stillScanning = 0; Index: Slim/DataStores/DBI/DataModel.pm =================================================================== --- Slim/DataStores/DBI/DataModel.pm (revision 3952) +++ Slim/DataStores/DBI/DataModel.pm (working copy) @@ -832,7 +832,7 @@ unless ($cleanupIds) { - $::d_import && msg("Starting stale cleanup for class $class / $foreign\n"); + $::d_import && msg("Import: Starting stale cleanup for class $class / $foreign\n"); $cleanupIds = $class->retrieveAllOnlyIds(); } @@ -843,7 +843,7 @@ if (!defined $obj && !defined $item && scalar @{$cleanupIds} == 0) { - $::d_import && msg("Finished stale cleanup for class $class / $foreign\n"); + $::d_import && msg("Import: Finished stale cleanup for class $class / $foreign\n"); $cleanupIds = undef; @@ -852,7 +852,7 @@ if ($obj && $obj->$foreign()->count() == 0) { - $::d_import && msg("DB garbage collection - removing $class: $obj - no more tracks!\n"); + $::d_import && msg("Import: DB garbage collection - removing $class: $obj - no more tracks!\n"); $obj->delete(); Index: Slim/DataStores/DBI/DBIStore.pm =================================================================== --- Slim/DataStores/DBI/DBIStore.pm (revision 3952) +++ Slim/DataStores/DBI/DBIStore.pm (working copy) @@ -607,7 +607,7 @@ # Setup a little state machine so that the db cleanup can be # scheduled appropriately - ie: one record per run. - $::d_import && msg("Adding task for cleanupStaleTrackEntries()..\n"); + $::d_import && msg("Import: Adding task for cleanupStaleTrackEntries()..\n"); Slim::Utils::Scheduler::add_task(\&cleanupStaleTrackEntries, $self); } @@ -640,7 +640,7 @@ # After that, walk the Album, Contributor & Genre tables, to see if # each item has valid tracks still. If it doesn't, remove the object. - $::d_import && msg("Starting db garbage collection..\n"); + $::d_import && msg("Import: Starting db garbage collection..\n"); $cleanupIds = Slim::DataStores::DBI::Track->retrieveAllOnlyIds; } @@ -656,7 +656,7 @@ if (!defined $track && !defined $item && scalar @{$cleanupIds} == 0) { $::d_import && msg( - "Finished with stale track cleanup. Adding tasks for Contributors, Albums & Genres.\n" + "Import: Finished with stale track cleanup. Adding tasks for Contributors, Albums & Genres.\n" ); $cleanupIds = undef; @@ -689,7 +689,7 @@ # Don't use _hasChanged - because that does more than we want. if (!-r $filepath) { - $::d_import && msg("Track: $filepath no longer exists. Removing.\n"); + $::d_import && msg("Import: Track $filepath no longer exists. Removing.\n"); $self->delete($track, 0); } @@ -733,7 +733,7 @@ # We're done. $self->dbh->commit; - $::d_import && msg("Finished with cleanupStaleTableEntries()\n"); + $::d_import && msg("Import: Finished with cleanupStaleTableEntries()\n"); %lastFind = (); @@ -765,7 +765,7 @@ if (!defined $obj && !defined $item && scalar @{$variousAlbumIds} == 0) { - $::d_import && msg("Finished with mergeVariousArtistsAlbums()\n"); + $::d_import && msg("Import: Finished with mergeVariousArtistsAlbums()\n"); $vaObj = undef; $variousAlbumIds = (); @@ -774,7 +774,7 @@ } if (!defined $obj) { - $::d_import && msg("mergeVariousArtistsAlbums: Couldn't fetch album for item: [$item]\n"); + $::d_import && msg("Import: mergeVariousArtistsAlbums: Couldn't fetch album for item: [$item]\n"); return 0; } @@ -801,7 +801,7 @@ return 1; } - $::d_import && msgf("Marking album: [%s] as Various Artists.\n", $obj->title); + $::d_import && msgf("Import: Marking album: [%s] as Various Artists.\n", $obj->title); $obj->compilation(1); $obj->contributor($vaObj); @@ -837,7 +837,7 @@ Slim::DataStores::DBI::DataModel->clearObjectCaches(); - $::d_import && msg("wipeAllData: Wiped all in-memory caches.\n"); + $::d_import && msg("Import: Wiped all in-memory caches.\n"); } # Wipe all data in the database @@ -858,7 +858,7 @@ Slim::DataStores::DBI::DataModel->wipeDB(); - $::d_import && msg("wipeAllData: Wiped info database\n"); + $::d_import && msg("Import: Wiped info database\n"); } # Force a commit of the database Index: Plugins/MusicMagic/Plugin.pm =================================================================== --- Plugins/MusicMagic/Plugin.pm (revision 3952) +++ Plugins/MusicMagic/Plugin.pm (working copy) @@ -308,8 +308,10 @@ sub stopScan { if (stillScanning()) { + + $::d_musicmagic && msg("MusicMagic: Scan already in progress. Restarting\n"); Slim::Utils::Scheduler::remove_task(\&exportFunction); - doneScanning(); + $isScanning = 0; } } Index: Plugins/iTunes.pm =================================================================== --- Plugins/iTunes.pm (revision 3952) +++ Plugins/iTunes.pm (working copy) @@ -533,7 +533,13 @@ $::d_itunes && msg("iTunes: Was stillScanning - stopping old scan.\n"); Slim::Utils::Scheduler::remove_task(\&scanFunction); - doneScanning(); + $isScanning = 0; + $locked = 0; + $opened = 0; + + close(ITUNESLIBRARY); + $iTunesParser = undef; + resetScanState(); } } Index: Plugins/MoodLogic/Plugin.pm =================================================================== --- Plugins/MoodLogic/Plugin.pm (revision 3952) +++ Plugins/MoodLogic/Plugin.pm (working copy) @@ -261,8 +261,10 @@ sub stopScan { if (stillScanning()) { + $::d_moodlogic && msg("MoodLogic: Scan already in progress. Restarting\n"); Slim::Utils::Scheduler::remove_task(\&exportFunction); - doneScanning(); + $isScanning = 0; + %genre_hash = (); } }