Skip to content

Commit

Permalink
Merge branch 'release/1.1.10'
Browse files Browse the repository at this point in the history
* release/1.1.10:
  Update version_check.php
  Update changelog
  Don't crash if tray icon double-clicked and no ActionTarget set
  Hopefully sort ouf the false events skipped thing
  Add a missing event type
  Fixed my botched attempt to nuke the browser cache
  Try another way of busting the cache
  Don't try and deserialize folder type.
  7zip: assume yes to all queries
  Disable CEF application cache
  Don't crash and burn if there's an unexpected exception starting Syncthing
  Add a bunch more logging to the update system
  Remove a random 'String1' resource string
  Log why updates are ignored (too low, user ignored, etc)
  Address race condition when re-fetching config
  Change Folder ReadOnly to Type
  • Loading branch information
canton7 committed May 19, 2016
2 parents 9e8a245 + d1133dc commit 698995d
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 54 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

v1.1.10
-------

- Ship with Syncthing 0.13 by default (only affects new users)
- Fix race condition when reloading config (#259)
- Don't show 'Finished Syncthing' halfway through a busy sync (#264)
- Don't crash when right-clicking tray icon early in startup process (#257)
- Attempt to fix issue where UI half-renders after update to Syncthing 0.13 (#262)

v1.1.9
------

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace :portable do
cp_to_portable(portable_dir, arch_config.syncthing_binaries[PORTABLE_SYNCTHING_VERSION], 'syncthing.exe')
end

sh %Q{"#{SZIP}" a -tzip -mx=7 #{arch_config.portable_output_file} #{portable_dir}}
sh %Q{"#{SZIP}" a -tzip -mx=7 -y #{arch_config.portable_output_file} #{portable_dir}}
end
end
end
Expand Down Expand Up @@ -301,7 +301,7 @@ namespace :syncthing do
sh CHECKSUM_UTIL_EXE, 'verify', File.join(tmp, 'sha1sum.txt.asc'), 'sha1', SYNCTHING_RELEASES_CERT, download_file

Dir.chdir(tmp) do
sh %Q{"#{SZIP}" e #{File.basename(download_file)}}
sh %Q{"#{SZIP}" e -y #{File.basename(download_file)}}
end

cp File.join(tmp, 'syncthing.exe'), File.join(arch_config.installer_dir, 'syncthing.exe')
Expand Down
5 changes: 3 additions & 2 deletions server/version_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function get_with_wildcard($src, $value, $default = null)
}

$versions = [
'1.1.9' => [
'1.1.10' => [
'installed' => [
'direct_download_url' => [
'x64' => 'https://github.com/canton7/SyncTrayzor/releases/download/v{version}/SyncTrayzorSetup-x64.exe',
Expand All @@ -81,11 +81,12 @@ function get_with_wildcard($src, $value, $default = null)
'sha1sum_download_url' => 'https://github.com/canton7/SyncTrayzor/releases/download/v{version}/sha1sum.txt.asc',
'sha512sum_download_url' => 'https://github.com/canton7/SyncTrayzor/releases/download/v{version}/sha512sum.txt.asc',
'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v{version}',
'release_notes' => "- Add support for Syncthing v0.13\n- Add setting to control tray icon animation\n- Don't refresh browser when un-minimizing\n- Don't crash if the filesystem watcher sees a change at the drive root\n- Handle filesystem notifications when Syncthing is configured with a path of the wrong case\n- Clarify wording when device paused by metered network",
'release_notes' => "- Fix race condition when reloading config (#259)\n- Don't show 'Finished Syncthing' halfway through a busy sync (#264)\n- Don't crash when right-clicking tray icon early in startup process (#257)\n- Attempt to fix issue where UI half-renders after update to Syncthing 0.13 (#262)",
]
];

$upgrades = [
'1.1.9' => ['to' => 'latest', 'formatter' => '5'],
'1.1.8' => ['to' => 'latest', 'formatter' => '5'],
'1.1.7' => ['to' => 'latest', 'formatter' => '4'],
'1.1.6' => ['to' => 'latest', 'formatter' => '4'],
Expand Down
2 changes: 1 addition & 1 deletion src/SyncTrayzor/NotifyIcon/TaskbarIconResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<tb:TaskbarIcon x:Key="TaskbarIcon" x:Name="TaskbarIcon"
Visibility="{Binding Visible, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
DoubleClickCommand="{s:Action DoubleClick}"
DoubleClickCommand="{s:Action DoubleClick, ActionNotFound=Disable}"
MenuActivation="RightClick">
<tb:TaskbarIcon.TrayPopup>
<Popup StaysOpen="False" Placement="Relative" HorizontalOffset="-150" VerticalOffset="100" Width="300" PlacementTarget="{Binding ElementName=TaskbarIcon}" AllowsTransparency="True">
Expand Down
5 changes: 5 additions & 0 deletions src/SyncTrayzor/Pages/ViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ protected override void OnInitialActivate()
{
settings.CefCommandLineArgs.Add("disable-gpu", "1");
settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1");
settings.CefCommandLineArgs.Add("disable-cache", "1");
settings.CefCommandLineArgs.Add("disable-application-cache", "1");
}

Cef.Initialize(settings);
Expand Down Expand Up @@ -180,7 +182,10 @@ public void RefreshBrowser()
{
this.Location = "about:blank";
if (this.syncthingManager.State == SyncthingState.Running)
{
this.Location = this.GetSyncthingAddress().ToString();
//this.WebBrowser?.Reload(ignoreCache: true);
}
}

public void ZoomIn()
Expand Down
9 changes: 0 additions & 9 deletions src/SyncTrayzor/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/SyncTrayzor/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,6 @@ Do you want to restart SyncTrayzor now?</value>
<value>The following {0:p:device has|devices have} been paused because {0:p:it|they} connected using a metered network: {0:l:{}|, }.</value>
<comment>{0}: List of paused devices</comment>
</data>
<data name="String1" xml:space="preserve">
<value />
</data>
<data name="SettingsView_MeteredNetworks" xml:space="preserve">
<value>Pause devices which connect over a metered network</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using NLog;
using System;
using System.Threading.Tasks;

namespace SyncTrayzor.Services.UpdateManagement
{
public class InstalledUpdateVariantHandler : IUpdateVariantHandler
{
private const string updateDownloadFileName = "SyncTrayzorUpdate-{0}.exe";
private static readonly ILogger logger = LogManager.GetCurrentClassLogger();

private readonly IUpdateDownloader updateDownloader;
private readonly IProcessStartProvider processStartProvider;
Expand Down Expand Up @@ -37,6 +39,7 @@ public async Task<bool> TryHandleUpdateAvailableAsync(VersionCheckResults checkR
}
else
{
logger.Info($"Can't auto-install, as DownloadUrl is {checkResult.DownloadUrl} and sha512sumDownloadUrl is {checkResult.Sha512sumDownloadUrl}");
// Can continue, but not auto-install
this.CanAutoInstall = false;

Expand Down
6 changes: 6 additions & 0 deletions src/SyncTrayzor/Services/UpdateManagement/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ public async Task<VersionCheckResults> CheckForAcceptableUpdateAsync(Version lat
return null;

if (results.NewVersion <= this.applicationVersion)
{
logger.Warn($"Found update, but it's <= the current application version ({this.applicationVersion}), so ignoring");
return null;
}

if (latestIgnoredVersion != null && results.NewVersion <= latestIgnoredVersion)
{
logger.Info($"Found update, but it's <= the latest ignored version ({latestIgnoredVersion}), so ignoring");
return null;
}

return results;
}
Expand Down
2 changes: 2 additions & 0 deletions src/SyncTrayzor/Services/UpdateManagement/UpdateDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public async Task<string> DownloadUpdateAsync(string updateUrl, string sha512sum
bool downloaded = await this.TryDownloadToFileAsync(downloadPath, url);
if (!downloaded)
{
logger.Warn("Problem downloading the file. Aborting");
// EXIT POINT
return Tuple.Create(false, default(T));
}
Expand All @@ -123,6 +124,7 @@ public async Task<string> DownloadUpdateAsync(string updateUrl, string sha512sum
}

// EXIT POINT
logger.Info($"Downloaded validation result: {downloadedValidationResult}");
return downloadedValidationResult;
}
catch (Exception e)
Expand Down
6 changes: 6 additions & 0 deletions src/SyncTrayzor/Services/UpdateManagement/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ private async Task CheckForUpdatesAsync()
return;

if (!await variantHandler.TryHandleUpdateAvailableAsync(checkResult))
{
logger.Info("Can't update, as TryHandleUpdateAvailableAsync returned false");
return;
}

VersionPromptResult promptResult;
if (this.applicationState.HasMainWindow)
Expand All @@ -211,7 +214,10 @@ private async Task CheckForUpdatesAsync()
{
// If another application is fullscreen, don't bother
if (this.userActivityMonitor.IsWindowFullscreen())
{
logger.Info("Another application was fullscreen, so we didn't prompt the user");
return;
}

try
{
Expand Down
39 changes: 20 additions & 19 deletions src/SyncTrayzor/Syncthing/ApiClient/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SyncTrayzor.Syncthing.ApiClient
{
public class ConfigFolderDevice : IEquatable<ConfigFolderDevice>
{
[JsonProperty("DeviceID")]
[JsonProperty("deviceId")]
public string DeviceId { get; set; }

public bool Equals(ConfigFolderDevice other)
Expand All @@ -23,19 +23,20 @@ public override string ToString()

public class ConfigFolder : IEquatable<ConfigFolder>
{
[JsonProperty("ID")]
[JsonProperty("id")]
public string ID { get; set; }

[JsonProperty("Path")]
[JsonProperty("path")]
public string Path { get; set; }

[JsonProperty("Devices")]
[JsonProperty("devices")]
public List<ConfigFolderDevice> Devices { get; set; }

[JsonProperty("ReadOnly")]
public bool ReadOnly { get; set; }
// This has changed type, and we don't use it anyway
//[JsonProperty("type")]
//public bool Type { get; set; }

[JsonProperty("RescanIntervalS")]
[JsonProperty("rescanIntervalS")]
public long RescanIntervalSeconds { get; set; }

public TimeSpan RescanInterval
Expand All @@ -53,37 +54,37 @@ public bool Equals(ConfigFolder other)
this.ID == other.ID &&
this.Path == other.Path &&
this.Devices.SequenceEqual(other.Devices) &&
this.ReadOnly == other.ReadOnly &&
//this.Type == other.Type &&
this.RescanIntervalSeconds == other.RescanIntervalSeconds &&
this.Invalid == other.Invalid;
}

public override string ToString()
{
return $"<Folder id={this.ID} path={this.Path} devices=[{String.Join(", ", this.Devices)}] readonly={this.ReadOnly} rescalinterval={this.RescanInterval} invalid={this.Invalid}>";
return $"<Folder id={this.ID} path={this.Path} devices=[{String.Join(", ", this.Devices)}] rescalinterval={this.RescanInterval} invalid={this.Invalid}>";
}
}

public class ConfigDevice : IEquatable<ConfigDevice>
{
[JsonProperty("DeviceID")]
[JsonProperty("deviceID")]
public string DeviceID { get; set; }

[JsonProperty("Name")]
[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("Addresses")]
[JsonProperty("addresses")]
public List<string> Addresses { get; set; }

// Apparently this can be 'never'
// We don't use it, so commenting until it decided what data type it wants to be
//[JsonProperty("Compression")]
//public bool Compression { get; set; }
//[JsonProperty("compression")]
//public string Compression { get; set; }

[JsonProperty("CertName")]
[JsonProperty("certName")]
public string CertName { get; set; }

[JsonProperty("Introducer")]
[JsonProperty("introducer")]
public bool IsIntroducer { get; set; }

public bool Equals(ConfigDevice other)
Expand All @@ -104,13 +105,13 @@ public override string ToString()

public class Config : IEquatable<Config>
{
[JsonProperty("Version")]
[JsonProperty("version")]
public long Version { get; set; }

[JsonProperty("Folders")]
[JsonProperty("folders")]
public List<ConfigFolder> Folders { get; set; }

[JsonProperty("Devices")]
[JsonProperty("devices")]
public List<ConfigDevice> Devices { get; set; }

public bool Equals(Config other)
Expand Down
1 change: 1 addition & 0 deletions src/SyncTrayzor/Syncthing/ApiClient/EventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ public enum EventType
ListenAddressChanged,
RelayStateChanged,
ExternalPortMappingChanged,
ListenAddressesChanged,
}
}
20 changes: 9 additions & 11 deletions src/SyncTrayzor/Syncthing/EventWatcher/SyncthingEventWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@ protected override async Task PollAsync(CancellationToken cancellationToken)

logger.Debug("Received {0} events", events.Count);

// Need to synchronously update the lastEventId
var oldLastEventId = this.lastEventId;
this.lastEventId = events[events.Count - 1].Id;
if (events.Count > 0)
{
// Assume we won't skip events in the middle of a response, just before it
bool skippedEvents = (this.lastEventId > 0 && (events[0].Id - this.lastEventId) != 1);
this.lastEventId = events[events.Count - 1].Id;

this.ProcessEvents(oldLastEventId, events, cancellationToken);
this.ProcessEvents(skippedEvents, events, cancellationToken);
}
}

private async void ProcessEvents(int startingEventId, List<Event> events, CancellationToken cancellationToken)
private async void ProcessEvents(bool skippedEvents, List<Event> events, CancellationToken cancellationToken)
{
// Shove off the processing to another thread - means we can get back to polling quicker
// However the task factory we use has a limited concurrency level of 1, so we won't process events out-of-order
Expand All @@ -100,19 +103,14 @@ private async void ProcessEvents(int startingEventId, List<Event> events, Cancel
{
return this.taskFactory.StartNew(() =>
{
bool eventsSkipped = false;
// We receive events in ascending ID order
foreach (var evt in events)
{
if (startingEventId > 0 && (evt.Id - startingEventId) != 1)
eventsSkipped = true;
startingEventId = evt.Id;
logger.Debug(evt);
evt.Visit(this);
}
if (eventsSkipped)
if (skippedEvents)
{
logger.Debug("Events were skipped");
this.OnEventsSkipped();
Expand Down
15 changes: 9 additions & 6 deletions src/SyncTrayzor/Syncthing/SyncthingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,20 @@ private async Task StartClientAsync()
catch (ApiException e)
{
var msg = $"RestEase Error. StatusCode: {e.StatusCode}. Content: {e.Content}. Reason: {e.ReasonPhrase}";
logger.Error(msg, e);
logger.Error(e, msg);
throw new SyncthingDidNotStartCorrectlyException(msg, e);
}
catch (HttpRequestException e)
{
var msg = $"HttpRequestException while starting Syncthing: {e.Message}";
logger.Error(msg, e);
logger.Error(e, msg);
throw new SyncthingDidNotStartCorrectlyException(msg, e);
}
catch (Exception e)
{
logger.Error(e, "Error starting Syncthing API");
throw;
var msg = $"Unexpected exception while starting Syncthing: {e.Message}";
logger.Error(e, msg);
throw new SyncthingDidNotStartCorrectlyException(msg, e);
}
}

Expand Down Expand Up @@ -447,8 +448,8 @@ private async Task LoadStartupDataAsync(CancellationToken cancellationToken)

// There's a race where Syncthing died, and so we kill the API clients and set it to null,
// but we still end up here, because threading.
var apiClient = this.apiClient.Value;
cancellationToken.ThrowIfCancellationRequested();
var apiClient = this.apiClient.GetAsserted();

var syncthingVersionTask = apiClient.FetchVersionAsync();
var systemInfoTask = apiClient.FetchSystemInfoAsync();
Expand Down Expand Up @@ -477,7 +478,9 @@ private async Task LoadStartupDataAsync(CancellationToken cancellationToken)

private async Task LoadConfigDataAsync(string tilde, bool isReload, CancellationToken cancellationToken)
{
var apiClient = this.apiClient.GetAsserted();
// We can end up here just as Syncthing is restarting
var apiClient = this.apiClient.Value;
cancellationToken.ThrowIfCancellationRequested();

var config = await apiClient.FetchConfigAsync();
cancellationToken.ThrowIfCancellationRequested();
Expand Down

0 comments on commit 698995d

Please sign in to comment.