Skip to content

Commit

Permalink
Merge branch 'release/1.1.22'
Browse files Browse the repository at this point in the history
* release/1.1.22:
  Update version_check.php
  Update changelog
  Fix memory leak in the tray icon
  Fix crash in ApplicationWindowState.Dispose
  Try harder not to cache resouces
  Allow STTRACE to be set in env vars
  Clear failed start records when we give up
  Add tray button to rescan all folders
  Don't crash if GridViewColumnHeader.Column is null
  Swallow some errors in PipeServer
  Use folder label, not ID, in file transfers progress tooltip
  Disable CefSharp logging
  Refresh local list of folders when config saved, not on Syncthing load
  • Loading branch information
canton7 committed Oct 5, 2018
2 parents 9f8d438 + eea3ac1 commit b287efc
Show file tree
Hide file tree
Showing 21 changed files with 214 additions and 133 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

v1.1.22
-------

- Fix some crashes (#443, #463, #468, #471)
- Show the folder name, not ID, in the file transfers progress tooltip (#457)
- Add tray button to rescan all folders (#465)
- Show change in Syncthing theme without requiring refresh (#472)
- Allow STTRACE to be set in env vars in settings (#473)
- Fix slow memory leak (#479)

v1.1.21
-------

Expand Down
104 changes: 62 additions & 42 deletions server/version_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ function get_with_wildcard($src, $value, $default = null)
}

$versions = [
'1.1.22' => [
'base_url' => 'https://github.com/canton7/SyncTrayzor/releases/download',
'installed' => [
'direct_download_url' => [
'x64' => "{base_url}/v{version}/SyncTrayzorSetup-x64.exe",
'x86' => "{base_url}/v{version}/SyncTrayzorSetup-x86.exe",
],
],
'portable' => [
'direct_download_url' => [
'x64' => "{base_url}/v{version}/SyncTrayzorPortable-x64.zip",
'x86' => "{base_url}/v{version}/SyncTrayzorPortable-x86.zip",
],
],
'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' => "- Fix some crashes (#443, #463, #468, #471)\n- Show the folder name, not ID, in the file transfers progress tooltip (#457)\n- Add tray button to rescan all folders (#465)\n- Show change in Syncthing theme without requiring refresh (#472)\n- Allow STTRACE to be set in env vars in settings (#473)\n- Fix slow memory leak (#479)",
],
'1.1.21' => [
'base_url' => 'https://synctrayzor.antonymale.co.uk/download',
'installed' => [
Expand All @@ -82,55 +101,56 @@ 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' => "!!!!!\nYou must upgrade to v1.1.21 now, otherwise auto-upgrades will stop working!\n!!!!!\n\n- Fix \"Syncthing failed to start correctly\" message when shutting down Windows (#438)\n- Handle \"Access denied\" errors when resolving conflicts (#440)",
'release_notes' => "!!!!!\nYou must upgrade to v1.1.21 now, otherwise auto-upgrades will stop working!\n!!!!!\n\nFurther upgrades will be available once you have upgraded to v1.1.21.",
]
];

$upgrades = [
// Github start supporting tls3 only, and versions prior to 1.1.20 didn't support this. 1.1.20 and 1.1.21 are hosted on my server. 1.1.20 can download
// directly from github, but versions prior have to use my server.
'1.1.20' => ['to' => 'latest', 'formatter' => '5', 'overrides' => ['base_url' => 'https://github.com/canton7/SyncTrayzor/releases/download', 'release_notes' => "- Fix \"Syncthing failed to start correctly\" message when shutting down Windows (#438)\n- Handle \"Access denied\" errors when resolving conflicts (#440)"]],
'1.1.19' => ['to' => 'latest', 'formatter' => '5'],
'1.1.18' => ['to' => 'latest', 'formatter' => '5'],
'1.1.17' => ['to' => 'latest', 'formatter' => '5'],
'1.1.16' => ['to' => 'latest', 'formatter' => '5'],
'1.1.15' => ['to' => 'latest', 'formatter' => '5'],
'1.1.14' => ['to' => 'latest', 'formatter' => '5'],
'1.1.13' => ['to' => 'latest', 'formatter' => '5'],
'1.1.12' => ['to' => 'latest', 'formatter' => '5'],
'1.1.11' => ['to' => 'latest', 'formatter' => '5'],
'1.1.10' => ['to' => 'latest', 'formatter' => '5'],
'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'],
'1.1.5' => ['to' => 'latest', 'formatter' => '4'],
'1.1.4' => ['to' => 'latest', 'formatter' => '4'],
'1.1.3' => ['to' => 'latest', 'formatter' => '4'],
'1.1.2' => ['to' => 'latest', 'formatter' => '4'],
'1.1.1' => ['to' => 'latest', 'formatter' => '3'],
'1.1.0' => ['to' => 'latest', 'formatter' => '3'],
'1.0.32' => ['to' => 'latest', 'formatter' => '3'],
'1.0.31' => ['to' => 'latest', 'formatter' => '3'],
'1.0.30' => ['to' => 'latest', 'formatter' => '3'],
'1.0.29' => ['to' => 'latest', 'formatter' => '3'],
'1.0.28' => ['to' => 'latest', 'formatter' => '3'],
'1.0.27' => ['to' => 'latest', 'formatter' => '3'],
'1.0.26' => ['to' => 'latest', 'formatter' => '3'],
'1.0.25' => ['to' => 'latest', 'formatter' => '3'],
'1.0.24' => ['to' => 'latest', 'formatter' => '3'],
'1.0.23' => ['to' => 'latest', 'formatter' => '3'],
'1.0.22' => ['to' => 'latest', 'formatter' => '2'],
'1.0.21' => ['to' => 'latest', 'formatter' => '2'],
'1.0.20' => ['to' => 'latest', 'formatter' => '2'],
'1.1.21' => ['to' => 'latest', 'formatter' => '5'],
'1.1.20' => ['to' => 'latest', 'formatter' => '5'],
'1.1.19' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.18' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.17' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.16' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.15' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.14' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.13' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.12' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.11' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.10' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.9' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.8' => ['to' => '1.1.21', 'formatter' => '5'],
'1.1.7' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.6' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.5' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.4' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.3' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.2' => ['to' => '1.1.21', 'formatter' => '4'],
'1.1.1' => ['to' => '1.1.21', 'formatter' => '3'],
'1.1.0' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.32' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.31' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.30' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.29' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.28' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.27' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.26' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.25' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.24' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.23' => ['to' => '1.1.21', 'formatter' => '3'],
'1.0.22' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.21' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.20' => ['to' => '1.1.21', 'formatter' => '2'],
// 1.0.19 was never actually released, so no need to represent it
'1.0.18' => ['to' => 'latest', 'formatter' => '2'],
'1.0.17' => ['to' => 'latest', 'formatter' => '2'],
'1.0.16' => ['to' => 'latest', 'formatter' => '2'],
'1.0.15' => ['to' => 'latest', 'formatter' => '2'],
'1.0.14' => ['to' => 'latest', 'formatter' => '2'],
'1.0.13' => ['to' => 'latest', 'formatter' => '1'],
'1.0.12' => ['to' => 'latest', 'formatter' => '1'],
'1.0.18' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.17' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.16' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.15' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.14' => ['to' => '1.1.21', 'formatter' => '2'],
'1.0.13' => ['to' => '1.1.21', 'formatter' => '1'],
'1.0.12' => ['to' => '1.1.21', 'formatter' => '1'],
];

$response_formatters = [
Expand Down
10 changes: 6 additions & 4 deletions src/SyncTrayzor/Design/DummyFileTransfersTrayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using SyncTrayzor.Pages;
using SyncTrayzor.Pages.Tray;
using SyncTrayzor.Syncthing.ApiClient;
using SyncTrayzor.Syncthing.Folders;
using SyncTrayzor.Syncthing.TransferHistory;

namespace SyncTrayzor.Design
Expand All @@ -23,20 +24,21 @@ public DummyFileTransfersTrayViewModel()
{
this.CompletedTransfers = new BindableCollection<FileTransferViewModel>();
this.InProgressTransfers = new BindableCollection<FileTransferViewModel>();
var folder = new Folder("folder", "Folder", "folderPath", false, FolderSyncState.Syncing, null);

var completedFileTransfer1 = new FileTransfer("folder", "path.pdf", ItemChangedItemType.File, ItemChangedActionType.Update);
var completedFileTransfer1 = new FileTransfer(folder, "path.pdf", ItemChangedItemType.File, ItemChangedActionType.Update);
completedFileTransfer1.SetComplete(null, false);

var completedFileTransfer2 = new FileTransfer("folder", "a really very long path that's far too long to sit on the page.h", ItemChangedItemType.File, ItemChangedActionType.Delete);
var completedFileTransfer2 = new FileTransfer(folder, "a really very long path that's far too long to sit on the page.h", ItemChangedItemType.File, ItemChangedActionType.Delete);
completedFileTransfer2.SetComplete("Something went very wrong", true);

//this.CompletedTransfers.Add(new FileTransferViewModel(completedFileTransfer1));
this.CompletedTransfers.Add(new FileTransferViewModel(completedFileTransfer2));

var inProgressTransfer1 = new FileTransfer("folder", "path.txt", ItemChangedItemType.File, ItemChangedActionType.Update);
var inProgressTransfer1 = new FileTransfer(folder, "path.txt", ItemChangedItemType.File, ItemChangedActionType.Update);
inProgressTransfer1.SetDownloadProgress(5*1024*1024, 100*1024*1024);

var inProgressTransfer2 = new FileTransfer("folder", "path", ItemChangedItemType.Dir, ItemChangedActionType.Update);
var inProgressTransfer2 = new FileTransfer(folder, "path", ItemChangedItemType.Dir, ItemChangedActionType.Update);

this.InProgressTransfers.Add(new FileTransferViewModel(inProgressTransfer1));
this.InProgressTransfers.Add(new FileTransferViewModel(inProgressTransfer2));
Expand Down
21 changes: 13 additions & 8 deletions src/SyncTrayzor/NotifyIcon/NotifyIconResolutionUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ private static void SetIconFromImageSource(TaskbarIcon taskbarIcon, ImageSource
if (imageSource != null)
{
Uri uri = new Uri(imageSource.ToString());
StreamResourceInfo streamInfo = Application.GetResourceStream(uri);
// The Icon ctor doesn't take ownership of the stream. This stream *does* however
// need to be disposed: PackagePart keeps a cache of streams which have been requested,
// and only releases them once they've been disposed, so the finalizer never gets a chance
// to kick in. See #479.
using (var stream = Application.GetResourceStream(uri)?.Stream)
{
if (stream == null)
{
string msg = "The supplied image source '{0}' could not be resolved.";
msg = String.Format(msg, imageSource);
throw new ArgumentException(msg);
}

if (streamInfo == null)
{
string msg = "The supplied image source '{0}' could not be resolved.";
msg = String.Format(msg, imageSource);
throw new ArgumentException(msg);
icon = new Icon(stream, idealIconSize, idealIconSize);
}

icon = new Icon(streamInfo.Stream, idealIconSize, idealIconSize);
}

taskbarIcon.Icon?.Dispose();
Expand Down
6 changes: 6 additions & 0 deletions src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public void Restart()
this.syncthingManager.RestartAsync();
}

public bool CanRescanAll => this.SyncthingState == SyncthingState.Running;
public void RescanAll()
{
this.syncthingManager.ScanAsync(null, null);
}

public void Exit()
{
this.OnExitRequested();
Expand Down
3 changes: 2 additions & 1 deletion src/SyncTrayzor/NotifyIcon/TaskbarIconResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<Separator Visibility="{Binding Folders, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
<MenuItem Header="{l:Loc TrayIcon_Menu_RescanAllFolders}" Command="{s:Action RescanAll, ActionNotFound=Disable}"/>
<Separator/>

<MenuItem Header="{l:Loc TrayIcon_Menu_StartSyncthing}" Command="{s:Action Start, ActionNotFound=Disable}"/>
<MenuItem Header="{l:Loc TrayIcon_Menu_StopSyncthing}" Command="{s:Action Stop, ActionNotFound=Disable}"/>
Expand Down
26 changes: 15 additions & 11 deletions src/SyncTrayzor/Pages/Settings/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,23 @@ private void LoadFromSyncthingStartupData()

this.FolderSettings.Clear();

var folderSettings = configuration.Folders.Select(x =>
{
this.syncthingManager.Folders.TryFetchById(x.ID, out var folder);
var folderSettings = new List<FolderSettings>(configuration.Folders.Count);

return new FolderSettings()
foreach (var configFolder in configuration.Folders)
{
if (this.syncthingManager.Folders.TryFetchById(configFolder.ID, out var folder))
{
FolderId = x.ID,
FolderLabel = folder?.Label ?? x.ID,
IsWatched = x.IsWatched,
IsWatchAllowed = !folder.IsFsWatcherEnabled,
IsNotified = x.NotificationsEnabled,
};
});
folderSettings.Add(new FolderSettings()
{
FolderId = configFolder.ID,
FolderLabel = folder?.Label ?? configFolder.ID,
IsWatched = configFolder.IsWatched,
IsWatchAllowed = !folder.IsFsWatcherEnabled,
IsNotified = configFolder.NotificationsEnabled,
});
}
}

this.FolderSettings.AddRange(folderSettings.OrderBy(x => x.FolderLabel));
this.IsAnyFolderWatchEnabledInSyncthing = this.FolderSettings.Any(x => !x.IsWatchAllowed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public SyncthingEnvironmentalVariablesValidator()
{
return KeyValueStringParser.TryParse(str, out var result);
}).WithMessage(Resources.SettingsView_Validation_SyncthingEnvironmentalVariablesMustHaveFormat);

RuleFor(x => x.Value).Must(str =>
{
KeyValueStringParser.TryParse(str, out var result);
return !result.Any(x => x.Key == "STTRACE");
}).WithMessage(Resources.SettingsView_Validation_SetSttraceInTab);
}
}
}
5 changes: 3 additions & 2 deletions src/SyncTrayzor/Pages/Tray/FileTransferViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Stylet;
using SyncTrayzor.Properties;
using SyncTrayzor.Syncthing.ApiClient;
using SyncTrayzor.Syncthing.Folders;
using SyncTrayzor.Syncthing.TransferHistory;
using SyncTrayzor.Utils;
using System;
Expand All @@ -22,7 +23,7 @@ public class FileTransferViewModel : PropertyChangedBase
private readonly DispatcherTimer completedTimeAgoUpdateTimer;

public string Path { get; }
public string FolderId { get; }
public Folder Folder { get; }
public string FullPath { get; }
public ImageSource Icon { get; }
public string Error { get; private set; }
Expand Down Expand Up @@ -56,7 +57,7 @@ public FileTransferViewModel(FileTransfer fileTransfer)
this.FileTransfer = fileTransfer;
this.Path = Pri.LongPath.Path.GetFileName(this.FileTransfer.Path);
this.FullPath = this.FileTransfer.Path;
this.FolderId = this.FileTransfer.FolderId;
this.Folder = this.FileTransfer.Folder;
using (var icon = ShellTools.GetIcon(this.FileTransfer.Path, this.FileTransfer.ItemType != ItemChangedItemType.Dir))
{
var bs = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
Expand Down
2 changes: 1 addition & 1 deletion src/SyncTrayzor/Pages/Tray/FileTransfersTrayView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<l:LocExtension Key="FileTransfersTrayView_PathDetails">
<l:LocExtension.ValueBindings>
<MultiBinding>
<Binding Path="FolderId"/>
<Binding Path="Folder.Label"/>
<Binding Path="FullPath"/>
</MultiBinding>
</l:LocExtension.ValueBindings>
Expand Down
6 changes: 2 additions & 4 deletions src/SyncTrayzor/Pages/Tray/FileTransfersTrayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,14 @@ private void UpdateConnectionStats(double? inBytesPerSecond, double? outBytesPer
public void ItemClicked(FileTransferViewModel fileTransferVm)
{
var fileTransfer = fileTransferVm.FileTransfer;
if (!this.syncthingManager.Folders.TryFetchById(fileTransfer.FolderId, out var folder))
return; // Huh? Nothing we can do about it...

// Not sure of the best way to deal with deletions yet...
if (fileTransfer.ActionType == ItemChangedActionType.Update)
{
if (fileTransfer.ItemType == ItemChangedItemType.File)
this.processStartProvider.ShowFileInExplorer(Path.Combine(folder.Path, fileTransfer.Path));
this.processStartProvider.ShowFileInExplorer(Path.Combine(fileTransferVm.Folder.Path, fileTransfer.Path));
else if (fileTransfer.ItemType == ItemChangedItemType.Dir)
this.processStartProvider.ShowFolderInExplorer(Path.Combine(folder.Path, fileTransfer.Path));
this.processStartProvider.ShowFolderInExplorer(Path.Combine(fileTransferVm.Folder.Path, fileTransfer.Path));
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/SyncTrayzor/Pages/ViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,17 @@ protected override void OnInitialActivate()
// We really only want to set the LocalStorage path, but we don't have that level of control....
CachePath = this.pathsProvider.CefCachePath,
IgnoreCertificateErrors = true,
LogSeverity = LogSeverity.Disable,
};

// System proxy settings (which also specify a proxy for localhost) shouldn't affect us
settings.CefCommandLineArgs.Add("no-proxy-server", "1");
settings.CefCommandLineArgs.Add("disable-cache", "1");

if (configuration.DisableHardwareRendering)
{
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");
}

Expand Down Expand Up @@ -342,6 +343,12 @@ CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl,
// and https://github.com/cefsharp/CefSharp/issues/534#issuecomment-60694502
var headers = request.Headers;
headers["X-API-Key"] = this.syncthingManager.ApiKey;

// I don't know why it adds these, even when we explicitly disable caching.
headers.Remove("Cache-Control");
headers.Remove("If-None-Match");
headers.Remove("If-Modified-Since");

lock (this.cultureLock)
{
if (this.culture != null)
Expand Down
Loading

0 comments on commit b287efc

Please sign in to comment.