/// <summary> /// Goes through all the mapsets in the queue and imports them. /// </summary> public static void ImportMapsetsInQueue() { Map selectedMap = null; if (MapManager.Selected.Value != null) { selectedMap = MapManager.Selected.Value; } for (var i = 0; i < Queue.Count; i++) { var file = Queue[i]; var time = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).Milliseconds; var extractDirectory = $@"{ConfigManager.SongDirectory}/{Path.GetFileNameWithoutExtension(file)} - {time}/"; ImportingMapset.Invoke(typeof(MapsetImporter), new ImportingMapsetEventArgs(Queue, Path.GetFileName(file), i)); try { if (file.EndsWith(".qp")) { ExtractQuaverMapset(file, extractDirectory); File.Delete(file); } else if (file.EndsWith(".osz")) { Osu.ConvertOsz(file, extractDirectory); File.Delete(file); } else if (file.EndsWith(".sm")) { Stepmania.ConvertFile(file, extractDirectory); } selectedMap = InsertAndUpdateSelectedMap(extractDirectory); Logger.Important($"Successfully imported {file}", LogType.Runtime); } catch (Exception e) { Logger.Error(e, LogType.Runtime); NotificationManager.Show(NotificationLevel.Error, $"Failed to import file: {Path.GetFileName(file)}"); } } MapDatabaseCache.OrderAndSetMapsets(); var mapset = MapManager.Mapsets.Find(x => x.Maps.Any(y => y.Md5Checksum == selectedMap?.Md5Checksum)); if (mapset == null) { mapset = MapManager.Mapsets.First(); MapManager.Selected.Value = mapset.Maps.First(); } else { MapManager.Selected.Value = mapset.Maps.Find(x => x.Md5Checksum == selectedMap?.Md5Checksum); } Queue.Clear(); }
/// <summary> /// Runs the worker thread for the sync process /// </summary> public static void RunThread() { if (!EligibleToSync) { return; } if (MapsToCache == null && ConfigManager.AutoLoadOsuBeatmaps.Value) { MapDatabaseCache.OrderAndSetMapsets(); } if (IsSyncing || !NeedsSync) { return; } Thread = new Thread(() => { if (MapsToCache != null && NeedsSync) { NotificationManager.Show(NotificationLevel.Info, $"Calculating difficulty ratings of other games' maps in the background. {SyncMapCount} maps left!"); Logger.Important($"Starting other game sync thread.", LogType.Runtime); } else { return; } using (var conn = new SQLiteConnection(DatabasePath)) { AddMaps(conn); UpdateMaps(conn); DeleteMaps(conn); if (SyncMapCount == 0) { NotificationManager.Show(NotificationLevel.Success, "Successfully completed difficulty rating calculations for other games!"); } } }) { IsBackground = true, Priority = ThreadPriority.AboveNormal }; Thread.Start(); }