public async Task StartBroadcastHandlers() { if (Config.UpdateSelf == true) { var officialExe = CurrentExe.GetFullPath(); if (await _verWatchr.NewVersionInstalled("FC-Updater")) { CurrentExe.Shutdown(); Process.Start(officialExe); } await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>( CheckerRelease.FileKey, CurrentExe.GetFullPath()); } await SetFirebaseHandler(); foreach (var kv in Config.BinaryFiles) { await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>(kv.Key, kv.Value); } foreach (var kv in Config.AppendOnlyDBs) { await StartNewHandler <AppendOnlyDbChangeBroadcastHandlerVM>(kv.Key, kv.Value); } foreach (var kv in Config.Executables) { await StartNewHandler <BinaryFileChangeBroadcastHandlerVM>(kv.Key, kv.Value); } }
public async Task <bool> NewVersionInstalled(string fileId, string exeFilePath = null) { if (exeFilePath.IsBlank()) { exeFilePath = CurrentExe.GetFullPath(); } var loccSHA1 = exeFilePath.SHA1ForFile(); await _agtState.SetState("Checking for updates", loccSHA1); var node = await _conn.GetNode <PublicFileInfo>(ROOTKEY, fileId, SUBKEY); if (node == null) { return(false); } if (loccSHA1 == node.SHA1) { await _agtState.SetRunningTask("Already running the latest version."); return(false); } await _agtState.SetRunningTask("Downloading newer version"); var tmp = await DownloadToTemp(node); var bkp = CreateBackupPath(exeFilePath); File.Move(exeFilePath, bkp); File.Move(tmp, exeFilePath); return(true); }
public Task SetState(string taskDesc, string exeSHA1 = null, string exeVersion = null) { var exe = CurrentExe.GetFullPath(); return(_conn.UpdateNode(new AgentState { RunningTask = taskDesc, LastActivity = DateTime.Now, ExeSHA1 = exeSHA1 ?? exe.SHA1ForFile(), ExeVersion = exeVersion ?? exe.GetVersion(), }, NodePath)); }
private static async void Vm_OnWindowHidden(object sender, EventArgs e) { if (_isChecking) { return; } _isChecking = true; var oldExe = CurrentExe.GetFullPath(); if (await _vChkr.NewVersionInstalled(_fileKey)) { CurrentExe.Shutdown(); Process.Start(oldExe); } _isChecking = false; }
public void StartChecking() => _watchr.StartWatching(CurrentExe.GetFullPath());