Skip to content

Commit

Permalink
don't instal an update automatically if more than one instance of Fes…
Browse files Browse the repository at this point in the history
…h is running.
  • Loading branch information
goswinr committed Jan 18, 2025
1 parent 61301be commit 9beab9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- don't instal an update automatically if more than one instance of Fesh is running.

## [0.20.0] - 2025-01-18
### Changed
- for portable version the location of SettingsFolder is inside the app folder now
Expand Down
16 changes: 13 additions & 3 deletions Src/Initialize.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module Initialize =
IFeshLog.log.PrintfnIOErrorMsg $"A newer version of Fesh is available: {nv} , you are using {cv}"
IFeshLog.log.PrintfnIOErrorMsg "Automattic updates are not available because Update.exe was not found in the parent folder."
IFeshLog.log.PrintfnIOErrorMsg "Please re-install from https://github.com/goswinr/Fesh/releases"

else
do! Async.SwitchToContext Fittings.SyncWpf.context
match MessageBox.Show(
Expand All @@ -91,9 +92,12 @@ module Initialize =
IFeshLog.log.PrintfnInfoMsg "All changes saved. Proceeding with update ..."
IFeshLog.log.PrintfnInfoMsg "Downloading Updates for Fesh ..."
do! Async.AwaitTask (updateManager.DownloadUpdatesAsync(updateInfo))
IFeshLog.log.PrintfnInfoMsg "Restarting Fesh to apply updates ..."
updateManager.ApplyUpdatesAndRestart(updateInfo)
IFeshLog.log.PrintfnInfoMsg "Updates for Fesh applied. Please restart the application."
if Diagnostics.Process.GetProcessesByName("Fesh").Length > 1 then
IFeshLog.log.PrintfnIOErrorMsg "Fesh is running multiple times. Please restart the application manually to apply updates."
else
IFeshLog.log.PrintfnInfoMsg "Restarting Fesh to apply updates ..."
updateManager.ApplyUpdatesAndRestart(updateInfo)
IFeshLog.log.PrintfnInfoMsg "Updates for Fesh applied. Restarting the application..."
else
IFeshLog.log.PrintfnIOErrorMsg "Some changes could not be saved. Update of Fesh cancelled."
| r ->
Expand All @@ -102,6 +106,12 @@ module Initialize =
IFeshLog.log.PrintfnInfoMsg "Could not check for Velopack updates: %A" e
} |> Async.Start

let velopackRun() =
let justOne = Diagnostics.Process.GetProcessesByName("Fesh").Length = 1
VelopackApp.Build()
.SetAutoApplyOnStartup(justOne) // there maybe an unapplied update available if more than one fesh was running, only apply if there is only one now.
.Run() //https://docs.velopack.io/getting-started/csharp

let saveBeforeFailing()=
async{
try
Expand Down

0 comments on commit 9beab9d

Please sign in to comment.