diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e7ea0a8..2907d8e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,18 @@ Changelog ========= +v1.1.19 +------- + + - Don't crash in rare cases trying to detect if Intel Xe Graphics in use (#626) + - Make it clearer that balloon settings are on the Folders tab (#613) + - Don't show device connectivity balloons by default + - Uninstaller: try to shut down running SyncTrayzor instances (#516) + v1.1.28 ------- - - Work around Intel X2 Graphics driver bug which causes Syncthing's UI to appear blank (#606) + - Work around Intel Xe Graphics driver bug which causes Syncthing's UI to appear blank (#606) - Fix chocolatey package (#614) v1.1.27 diff --git a/chocolatey/synctrayzor.nuspec b/chocolatey/synctrayzor.nuspec index 2f3767fb..3ac1fd25 100644 --- a/chocolatey/synctrayzor.nuspec +++ b/chocolatey/synctrayzor.nuspec @@ -8,7 +8,7 @@ 0.0.0 Antony Male Antony Male - Windows tray utility / filesystem watcher / launcher for syncthing + Windows tray utility / launcher for Syncthing SyncTrayzor is a little tray utility for [Syncthing](http://syncthing.net/) on Windows. It hosts and wraps Syncthing, making it behave more like a native Windows application and less like a command-line utility with a web browser interface. @@ -23,11 +23,6 @@ Features include: - One of your folders is out of sync - Folders finish syncing - Devices connect / disconnect - - Can watch your folders for changes, so you don't have to poll them frequently: - - Syncthing on its own has to poll your folders, in order to see if any files have changed. - - SyncTrayzor will watch your folders for changes, and alert Syncthing the second anything changes. - - This means you can increase the polling interval in Syncthing, avoiding the resource usage of high-frequency polling, but still have any changes propagated straight away. - - Folder watching respects the ignores configured in Syncthing. - Has a tool to help you resolve file conflicts - Contains translations for many languages @@ -43,7 +38,7 @@ Features include: https://cdn.statically.io/gh/canton7/SyncTrayzor/develop/SyncTrayzor.png - + diff --git a/chocolatey/tools/chocolateyinstall.ps1 b/chocolatey/tools/chocolateyinstall.ps1 index b960eb28..c1f24b92 100644 --- a/chocolatey/tools/chocolateyinstall.ps1 +++ b/chocolatey/tools/chocolateyinstall.ps1 @@ -1,13 +1,80 @@ $ErrorActionPreference = 'Stop'; # stop on all errors + +# Copied from https://github.com/chocolatey-community/chocolatey-coreteampackages/blob/a2371345f182da74589897055e3b3703deb0cce3/extensions/chocolatey-core.extension/extensions/Get-UninstallRegistryKey.ps1 +function Get-UninstallRegistryKeySilent { + param( + [Parameter(Mandatory=$true, ValueFromPipeline=$true)] + [ValidateNotNullOrEmpty()] + [string] $SoftwareName, + [parameter(ValueFromRemainingArguments = $true)] + [Object[]] $IgnoredArguments + ) + Write-Debug "Running 'Get-UninstallRegistryKey' for `'$env:ChocolateyPackageName`' with SoftwareName:`'$SoftwareName`'"; + + $ErrorActionPreference = 'Stop' + $local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' + $machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' + $machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' + + Write-Verbose "Retrieving all uninstall registry keys" + [array]$keys = Get-ChildItem -Path @($machine_key6432, $machine_key, $local_key) -ea 0 + Write-Debug "Registry uninstall keys on system: $($keys.Count)" + + Write-Debug "Error handling check: `'Get-ItemProperty`' fails if a registry key is encoded incorrectly." + [int]$maxAttempts = $keys.Count + for ([int]$attempt = 1; $attempt -le $maxAttempts; $attempt++) + { + $success = $false + + $keyPaths = $keys | Select-Object -ExpandProperty PSPath + try { + [array]$foundKey = Get-ItemProperty -Path $keyPaths -ea 0 | ? { $_.DisplayName -like $SoftwareName } + $success = $true + } catch { + Write-Debug "Found bad key." + foreach ($key in $keys){ try{ Get-ItemProperty $key.PsPath > $null } catch { $badKey = $key.PsPath }} + Write-Verbose "Skipping bad key: $badKey" + [array]$keys = $keys | ? { $badKey -NotContains $_.PsPath } + } + + if ($success) { break; } + if ($attempt -eq 10) { + Write-Warning "Found more than 10 bad registry keys. Run command again with `'--verbose --debug`' for more info." + Write-Debug "Each key searched should correspond to an installed program. It is very unlikely to have more than a few programs with incorrectly encoded keys, if any at all. This may be indicative of one or more corrupted registry branches." + } + } + + Write-Debug "Found $($foundKey.Count) uninstall registry key(s) with SoftwareName:`'$SoftwareName`'"; + return $foundKey +} + $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$file = (Join-Path $toolsDir 'SyncTrayzorSetup-x86.exe') +$file64 = (Join-Path $toolsDir 'SyncTrayzorSetup-x64.exe') + +$packageArgs = @{ + packageName = 'SyncTrayzor' + file = $file + file64 = $file64 + silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /SkipDotNetInstall' + fileType = 'exe' + validExitCodes = @(0) +} -$packageName= 'SyncTrayzor' -$file = (Join-Path $toolsDir 'SyncTrayzorSetup-x86.exe') -$file64 = (Join-Path $toolsDir 'SyncTrayzorSetup-x64.exe') -$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /SkipDotNetInstall' -$fileType = 'exe' -$validExitCodes = @(0) +# Version 1.1.28 had a bug which installed x86 on x64 machines. Forcefully transitioning someone from +# x86 to x64 is risky, as it potentially loses their config, Syncthing version, etc. +# Therefore if they've got the x86 version and not the x64 version, upgrade using the x86 version to +# avoid breaking them. +if ((Get-OSArchitectureWidth -compare 64) -and ($env:chocolateyForceX86 -ne $true) -and (Get-UninstallRegistryKeySilent -SoftwareName 'SyncTrayzor (x86)*')) { + if (Get-UninstallRegistryKeySilent -SoftwareName 'SyncTrayzor (x64)*') { + Write-Host -ForegroundColor green "Both the 32-bit and 64-bit versions of SyncTrayzor are installed. Upgrading the 64-bit version." + } else { + Write-Host -ForegroundColor green "You have the 32-bit version of SyncTrayzor installed, so upgrading this. If you intended to install the 64-bit version, please uninstall the 32-bit version first." + # null out the 64 bit file parameter, so only the 32 bit file is available to install + $packageArgs['file64'] = $null + } +} -Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $file $file64 -validExitCodes $validExitCodes +Install-ChocolateyInstallPackage @packageArgs -Remove-Item -Force -ea 0 $file, $file64 \ No newline at end of file +Remove-Item -Force -ea 0 $file, $file64 diff --git a/chocolatey/tools/chocolateyuninstall.ps1 b/chocolatey/tools/chocolateyuninstall.ps1 deleted file mode 100644 index db2a5cd9..00000000 --- a/chocolatey/tools/chocolateyuninstall.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -$ErrorActionPreference = 'Stop'; # stop on all errors - -$packageName = 'SyncTrayzor' -$softwareName = 'SyncTrayzor*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique -$installerType = 'exe' -$silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -$validExitCodes = @(0) - -$uninstalled = $false -$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' -$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' - -[array]$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) ` - -ErrorAction SilentlyContinue ` - | ? { $_.DisplayName -like "$softwareName" } - -if ($key.Count -eq 1) { - $key | % { - $file = "$($_.UninstallString)" - Uninstall-ChocolateyPackage -PackageName $packageName ` - -FileType $installerType ` - -SilentArgs "$silentArgs" ` - -ValidExitCodes $validExitCodes ` - -File "$file" - } -} elseif ($key.Count -eq 0) { - Write-Warning "$packageName has already been uninstalled by other means." -} elseif ($key.Count -gt 1) { - Write-Warning "$key.Count matches found!" - Write-Warning "To prevent accidental data loss, no programs will be uninstalled." - Write-Warning "Please alert package maintainer the following keys were matched:" - $key | % {Write-Warning "- $_.DisplayName"} -} diff --git a/installer/common.iss b/installer/common.iss index f814315e..8a14da56 100644 --- a/installer/common.iss +++ b/installer/common.iss @@ -324,9 +324,14 @@ begin end; end; +[UninstallRun] +Filename: "{app}\SyncTrayzor.exe"; Parameters: "--shutdown"; RunOnceId: "ShutdownSyncTrayzor"; Flags: skipifdoesntexist + [UninstallDelete] Type: files; Name: "{app}\ProcessRunner.exe.old" Type: files; Name: "{app}\InstallCount.txt" +; Not sure why this gets left behind, but it does. Clean it up... +Type: filesandordirs; Name: "{app}\locales" Type: filesandordirs; Name: "{userappdata}\{#AppDataFolder}" Type: filesandordirs; Name: "{localappdata}\{#AppDataFolder}" diff --git a/server/version_check.php b/server/version_check.php index abceccb9..459c17c9 100644 --- a/server/version_check.php +++ b/server/version_check.php @@ -65,7 +65,7 @@ function get_with_wildcard($src, $value, $default = null) } $versions = [ - '1.1.28' => [ + '1.1.29' => [ 'base_url' => 'https://github.com/canton7/SyncTrayzor/releases/download', 'installed' => [ 'direct_download_url' => [ @@ -82,7 +82,7 @@ function get_with_wildcard($src, $value, $default = null) 'sha1sum_download_url' => "{base_url}/v{version}/sha1sum.txt.asc", 'sha512sum_download_url' => "{base_url}/v{version}/sha512sum.txt.asc", 'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v{version}', - 'release_notes' => "Add a workaround for an Intel Xe graphics driver bug which causes Syncthing's UI to appear blank.\n\nIf you are not affected by this, you do not need to upgrade.", + 'release_notes' => "- Don't crash in rare cases trying to detect if Intel Xe Graphics in use (#626)\n- Make it clearer that balloon settings are on the Folders tab (#613)\n- Don't show device connectivity balloons by default\n- Uninstaller: try to shut down running SyncTrayzor instances (#516)", ], '1.1.21' => [ 'base_url' => 'https://synctrayzor.antonymale.co.uk/download', @@ -106,6 +106,7 @@ function get_with_wildcard($src, $value, $default = null) ]; $upgrades = [ + // Currently no need to upgrade people on 1.1.28 or 1.1.29 '1.1.27' => ['to' => 'latest', 'formatter' => '5'], '1.1.26' => ['to' => 'latest', 'formatter' => '5'], '1.1.25' => ['to' => 'latest', 'formatter' => '5'], diff --git a/src/SyncTrayzor/App.config b/src/SyncTrayzor/App.config index f136ce75..8e8c14d8 100644 --- a/src/SyncTrayzor/App.config +++ b/src/SyncTrayzor/App.config @@ -36,7 +36,7 @@ false false true - true + false false localhost:8384 true diff --git a/src/SyncTrayzor/Bootstrapper.cs b/src/SyncTrayzor/Bootstrapper.cs index fb07af52..bdc9fb84 100644 --- a/src/SyncTrayzor/Bootstrapper.cs +++ b/src/SyncTrayzor/Bootstrapper.cs @@ -119,6 +119,21 @@ protected override void Configure() { try { + if (this.options.Shutdown) + { + client.Shutdown(); + // Give it some time to shut down + var elapsed = Stopwatch.StartNew(); + while (elapsed.Elapsed < TimeSpan.FromSeconds(10) && + this.Container.Get().TryCreateClient() != null) + { + Thread.Sleep(100); + } + // Wait another half-second -- it seems it can take the browser process a little longer to exit + Thread.Sleep(500); + Environment.Exit(0); + } + if (this.options.StartSyncthing || this.options.StopSyncthing) { if (this.options.StartSyncthing) @@ -142,6 +157,12 @@ protected override void Configure() logger.Error(e, $"Failed to talk to {client}: {e.Message}. Pretending that it doesn't exist..."); } } + + // If we got this far, there probably isn't another instance running, and we should just shut down + if (this.options.Shutdown) + { + Environment.Exit(0); + } var configurationProvider = this.Container.Get(); configurationProvider.Initialize(AppSettings.Instance.DefaultUserConfiguration); @@ -346,7 +367,7 @@ protected override void OnExit(ExitEventArgs e) this.exiting = true; // Try and be nice and close SyncTrayzor gracefully, before the Dispose call on SyncthingProcessRunning kills it dead - this.Container.Get().StopAsync().Wait(500); + this.Container.Get().StopAndWaitAsync().Wait(2000); } public override void Dispose() diff --git a/src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs b/src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs index 1c7dbbc6..b528d17b 100644 --- a/src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs +++ b/src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs @@ -153,21 +153,21 @@ public async void Start() } public bool CanStop => this.SyncthingState == SyncthingState.Running; - public void Stop() + public async void Stop() { - this.syncthingManager.StopAsync(); + await this.syncthingManager.StopAsync(); } public bool CanRestart => this.SyncthingState == SyncthingState.Running; - public void Restart() + public async void Restart() { - this.syncthingManager.RestartAsync(); + await this.syncthingManager.RestartAsync(); } public bool CanRescanAll => this.SyncthingState == SyncthingState.Running; - public void RescanAll() + public async void RescanAll() { - this.syncthingManager.ScanAsync(null, null); + await this.syncthingManager.ScanAsync(null, null); } public void Exit() diff --git a/src/SyncTrayzor/Pages/Settings/SettingsView.xaml b/src/SyncTrayzor/Pages/Settings/SettingsView.xaml index f5d61dff..2582b194 100644 --- a/src/SyncTrayzor/Pages/Settings/SettingsView.xaml +++ b/src/SyncTrayzor/Pages/Settings/SettingsView.xaml @@ -65,7 +65,8 @@ - + - +