public static int Main(string[] args) { LegacyFilesystemReader.Register(); // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) { if (!host.IsPrimaryInstance) { var importer = new BeatmapIPCChannel(host); // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } } else { host.Run(new OsuGameDesktop(args)); } return(0); } }
public void TestImportOverIPC() { using (HeadlessGameHost host = new HeadlessGameHost("host", true)) using (HeadlessGameHost client = new HeadlessGameHost("client", true)) { Assert.IsTrue(host.IsPrimaryInstance); Assert.IsTrue(!client.IsPrimaryInstance); var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); Assert.IsTrue(File.Exists(temp)); var importer = new BeatmapIPCChannel(client); if (!importer.ImportAsync(temp).Wait(5000)) { Assert.Fail(@"IPC took too long to send"); } ensureLoaded(osu); Assert.IsFalse(File.Exists(temp)); } }
public void TestImportOverIPC() { using (HeadlessGameHost host = new CleanRunHeadlessGameHost("host", true)) using (HeadlessGameHost client = new CleanRunHeadlessGameHost("client", true)) { try { Assert.IsTrue(host.IsPrimaryInstance); Assert.IsFalse(client.IsPrimaryInstance); var osu = loadOsu(host); var temp = prepareTempCopy(osz_path); Assert.IsTrue(File.Exists(temp)); var importer = new BeatmapIPCChannel(client); if (!importer.ImportAsync(temp).Wait(10000)) { Assert.Fail(@"IPC took too long to send"); } ensureLoaded(osu); waitForOrAssert(() => !File.Exists(temp), "Temporary still exists after IPC import", 5000); } finally { host.Exit(); } } }
public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection) { this.rulesets = rulesets; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } }
public BeatmapManager(Storage storage, FileStore files, SQLiteConnection connection, RulesetStore rulesets, IIpcHost importHost = null) { beatmaps = new BeatmapStore(connection); beatmaps.BeatmapSetAdded += s => BeatmapSetAdded?.Invoke(s); beatmaps.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s); this.storage = storage; this.files = files; this.rulesets = rulesets; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } }
public BeatmapManager(Storage storage, Func <OsuDbContext> context, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null) { createContext = context; refreshImportContext(); beatmaps = createBeatmapStore(context); files = new FileStore(context, storage); this.storage = files.Storage; this.rulesets = rulesets; this.api = api; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } beatmaps.Cleanup(); }
public static int Main(string[] args) { // Back up the cwd before DesktopGameHost changes it var cwd = Environment.CurrentDirectory; using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true)) { if (!host.IsPrimaryInstance) { var importer = new BeatmapIPCChannel(host); // Restore the cwd so relative paths given at the command line work correctly Directory.SetCurrentDirectory(cwd); foreach (var file in args) { Console.WriteLine(@"Importing {0}", file); if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000)) { throw new TimeoutException(@"IPC took too long to send"); } } } else { #if DEBUG host.Run(new OsuTestBrowser()); #else switch (args.FirstOrDefault() ?? string.Empty) { case "--tests": host.Run(new OsuTestBrowser()); break; default: host.Run(new OsuGameDesktop(args)); break; } #endif } return(0); } }
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null) { this.contextFactory = contextFactory; beatmaps = new BeatmapStore(contextFactory); beatmaps.BeatmapSetAdded += s => BeatmapSetAdded?.Invoke(s); beatmaps.BeatmapSetRemoved += s => BeatmapSetRemoved?.Invoke(s); beatmaps.BeatmapHidden += b => BeatmapHidden?.Invoke(b); beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b); files = new FileStore(contextFactory, storage); this.rulesets = rulesets; this.api = api; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } beatmaps.Cleanup(); }
public BeatmapManager(Storage storage, Func <OsuDbContext> context, RulesetStore rulesets, APIAccess api, IIpcHost importHost = null) { createContext = context; importContext = new Lazy <OsuDbContext>(() => { var c = createContext(); c.Database.AutoTransactionsEnabled = false; return(c); }); beatmaps = createBeatmapStore(context); files = new FileStore(context, storage); this.storage = files.Storage; this.rulesets = rulesets; this.api = api; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } beatmaps.Cleanup(); }
public BeatmapDatabase(Storage storage, IIpcHost importHost = null) { this.storage = storage; if (importHost != null) { ipc = new BeatmapIPCChannel(importHost, this); } if (connection == null) { try { connection = prepareConnection(); deletePending(); } catch (Exception e) { Logger.Error(e, @"Failed to initialise the beatmap database! Trying again with a clean database..."); storage.DeleteDatabase(@"beatmaps"); connection = prepareConnection(); } } }