public void Update() { if (!IsUpdateAvailable()) { throw new LauncherException("no update is available"); } using (var mutex = new WurmAssistantMutex()) { mutex.Enter(1000, "You must close Wurm Assistant before running update"); var newFileZipped = WebApiClientSpellbook.GetFileFromWebApi( AppContext.WebApiBasePath, string.Format("{0}/{1}", AppContext.ProjectName, buildType), TimeSpan.FromSeconds(15), BasePath); using (var extractor = new SevenZipExtractor(newFileZipped.FullName)) { extractor.ExtractArchive(BasePath); } Thread.Sleep(1000); var cleaner = new DirCleaner(BasePath); cleaner.Cleanup(); } }
// run under WA mutex public void Import() { using (var mutex = new WurmAssistantMutex()) { mutex.Enter(1000, "You must close Wurm Assistant before running update"); } }
// run under WA mutex public void Execute() { var dirSet = new[] { AppContext.BetaInstallDir, AppContext.BetaDataDir, AppContext.StableInstallDir, AppContext.StableDataDir, AppContext.LauncherSettingsDir, AppContext.TempDir, AppContext.WaBackupBetaDir, AppContext.WaBackupStableDir }; bool dirsExist = CheckIfDirsExist(dirSet); bool portingOldDataDirRequired = false; var stableDir = new DirectoryInfo(AppContext.StableDataDir); if (!stableDir.Exists || (!stableDir.GetFiles().Any() && !stableDir.GetDirectories().Any())) { if (Directory.Exists(AppContext.OldDataDir)) { portingOldDataDirRequired = true; } } if (!dirsExist || !portingOldDataDirRequired) { using (var mutex = new WurmAssistantMutex()) { mutex.Enter(1000, "Wurm Assistant must be closed before launcher can finish initial setup"); if (!dirsExist) CreateDirsIfNotExists(dirSet); if (!portingOldDataDirRequired) CopyExistingWurmAssistantSettingsIfExist(); } } }