internal static void ProcessBeatmaps(bool newFilesOnly = false, bool quickFolderChecks = false) { SongWatcher.EnableRaisingEvents = false; QuickFolderChecks = quickFolderChecks; //Doing a full pass over the song folder is an expensive operation. //We should only do so if it is requested, or if we can't find the local osu!.db if (!newFilesOnly) { //FULL PROCESS Logger.LogPrint(@"_______________ Full process initiated. _______________"); //Mark every single beatmap as "not found" to begin with, then remove any remaining at the end which were not found. Beatmaps.ForEach(b => { b.DatabaseNotFound = true; b.HeadersLoaded = false; }); Root.Children.Clear(); Root.Beatmaps.Clear(); TotalUniqueSets = 0; TotalAudioOnly = 0; ProcessFolder(BeatmapManager.SongsDirectory); int removed = Beatmaps.RemoveAll(b => b.DatabaseNotFound); if (removed > 0) { InvokeOnStatusUpdate(string.Format(LocalisationManager.GetString(OsuString.BeatmapManager_RemoveMissingMaps), removed)); } ReloadDictionaries(); InvokeOnStatusUpdate(string.Format(LocalisationManager.GetString(OsuString.BeatmapManager_LoadedMaps), Beatmaps.Count)); } else { //PARTIAL PROCESS for (int j = 0; j < ChangedPackages.Count; j++) { string package = ChangedPackages[j]; if (!File.Exists(package)) { //Package is no longer with us :( Logger.Log($@"{package} could not be loaded. It no longer exists."); List <Beatmap> matches = Beatmaps.FindAll(b => b.ContainingFolderAbsolute == package); matches.ForEach(b => Remove(b)); continue; } else { BeatmapTreeLevel level = GetTreeLevel(Path.GetDirectoryName(package)); if (level != null) { ProcessPackage(package, level); } } } //Special processing for importing new maps //Changed to for loop because foreach was getting modified internally. not sure how this could happen. for (int j = 0; j < ChangedFolders.Count; j++) { string folder = ChangedFolders[j]; bool folderStillExists = Directory.Exists(folder); if (!folder.StartsWith(BeatmapManager.SongsDirectory)) { ProcessBeatmaps(); return; } BeatmapTreeLevel level = GetTreeLevel(folder); if (level == null) { continue; } if (level.Children.Count > 0 && folderStillExists) { //ignore this folder change for now? //sure, unless it was deleted. continue; } ResetTreeLevel(level); if (folderStillExists) { ProcessTree(level); } else { if (level.Parent != null) { level.Parent.Children.Remove(level); } } } } if (Current != null && newFilesOnly) { SetCurrentFromFilename(Current.Filename, false); } InitialLoadComplete = true; SongWatcher.EnableRaisingEvents = true; }