Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
canton7 committed Jan 13, 2016
2 parents 5c5048d + 481a113 commit b923f0c
Show file tree
Hide file tree
Showing 37 changed files with 642 additions and 224 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

v1.1.2
------

- Handle folders with missing markers again (#187)
- Don't crash in some cases on .NET 4.5 when the conflict editor is completed (#199)
- Don't crash if the ConflictFileWatcher is aborted (#200, #202)
- Don't show conflicts alerts bar if Syncthing isn't running
- Improve conflict file monitoring (should remove inaccuracies)
- Don't fail if there's a link loop when scanning for conflicted files (#195)
- Add 'Size' field to the conflict resolver (#194)
- Add setting to control whether conflict files are deleted to the recycle bin
- Pressing F5 will fresh the browser
- Fix the portable installation procedure (sorry portable users: you'll have to manually upgrade
one last time).

v1.1.1
------

Expand Down
16 changes: 9 additions & 7 deletions server/version_check.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,22 @@ function get_with_wildcard($src, $value, $default = null)
}

$versions = [
'1.1.1' => [
'1.1.2' => [
'installed' => [
'direct_download_url' => [
'x64' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.1/SyncTrayzorSetup-x64.exe',
'x86' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.1/SyncTrayzorSetup-x86.exe',
'x64' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.2/SyncTrayzorSetup-x64.exe',
'x86' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.2/SyncTrayzorSetup-x86.exe',
],
], 'sha1sum_download_url' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.1/sha1sum.txt.asc',
'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v1.1.1',
'release_notes' => "- Log Syncthing's output (#162).\n- Add a Settings tab to enable Syncthing debug facilities without setting STTRACE or restarting (#175).\n- Alerts system: show warning triangle on tray icon, and alerts at the top of SyncTrayzor, when there\n are failed file transfers or conflicted files.\n- Add a tool to find and help resolve file conflicts (under File -> Conflict Resolver).\n- Add support for one-click upgrades for Portable installations.\n- Improve 'Syncthing Console' (#82).\n- Improve update check schedule (#184).\n- Fix crash if the user manually specifies a UNC prefix on a folder (#192).",
],
'sha1sum_download_url' => 'https://github.com/canton7/SyncTrayzor/releases/download/v1.1.2/sha1sum.txt.asc',
'release_page_url' => 'https://github.com/canton7/SyncTrayzor/releases/tag/v1.1.2',
'release_notes' => "- Handle folders with missing markers again (#187)\n- Don't crash in some cases on .NET 4.5 when the conflict editor is completed (#199)\n- Don't crash if the ConflictFileWatcher is aborted (#200, #202)\n- Don't show conflicts alerts bar if Syncthing isn't running\n- Improve conflict file monitoring (should remove inaccuracies)\n- Don't fail if there's a link loop when scanning for conflicted files (#195)\n- Add 'Size' field to the conflict resolver (#194)\n- Add setting to control whether conflict files are deleted to the recycle bin\n- Pressing F5 will fresh the browser\n- Fix the portable installation procedure (sorry portable users: you'll have to manually upgrade\n one last time).",
]
];

$upgrades = [
'1.1.0' => ['to' => 'latest', 'formatter' => '3', 'overrides' => ['release_notes' => "- Fix crash if we fail to look for conflicted files in a path (#191, #193)\n- Fix crash if the user manually specifies a UNC prefix on a folder (#192)"]],
'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'],
Expand Down
3 changes: 3 additions & 0 deletions src/PortableInstaller/PortableInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SyncTrayzor\Utils\RecycleBinDeleter.cs">
<Link>RecycleBinDeleter.cs</Link>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
130 changes: 106 additions & 24 deletions src/PortableInstaller/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using SyncTrayzor.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand All @@ -12,6 +13,8 @@ class Program
{
static int Main(string[] args)
{
RecycleBinDeleter.Logger = s => Console.WriteLine("!! " + s);

if (args.Length != 4)
{
Console.WriteLine("You should not invoke this executable directly. It is used as part of the automatic upgrade process for portable installations.");
Expand All @@ -25,7 +28,9 @@ static int Main(string[] args)
var waitForPid = Int32.Parse(args[2]);
var pathToRestartApplication = args[3];

Console.WriteLine("Waiting for process to exit...");
bool pauseAtEnd = false;

Console.WriteLine("Waiting for SyncTrayzor process to exit...");
try
{
using (var process = Process.GetProcessById(waitForPid))
Expand All @@ -37,40 +42,86 @@ static int Main(string[] args)
catch (ArgumentException) // It wasn't running to start with. Coolio
{ }

// By default ou CWD is the destinationPath, which locks it
Directory.SetCurrentDirectory(Path.GetDirectoryName(destinationPath));
// By default our CWD is the destinationPath, which locks it
var cwd = Path.GetDirectoryName(destinationPath);
try
{
Directory.SetCurrentDirectory(cwd);
}
catch (Exception)
{
Console.WriteLine($"!! Unable to set working directory to {cwd}. None of your files have been touched.");
throw;
}

var destinationExists = Directory.Exists(destinationPath);

if (!Directory.Exists(sourcePath))
{
Console.WriteLine($"Unable to find source path {sourcePath}");
return 1;
Console.WriteLine($"!! Unable to find source path {sourcePath}. This is a bug with SyncTrayzor's upgrade mechanism.");
throw new Exception("Unable to find source path");
}

string movedDestinationPath = null;
if (destinationExists)
{
movedDestinationPath = GenerateBackupDestinationPath(destinationPath);
Console.WriteLine($"Moving {destinationPath} to {movedDestinationPath}");
Directory.Move(destinationPath, movedDestinationPath);
while (true)
{
Console.WriteLine($"Moving {destinationPath} to {movedDestinationPath}");
try
{
Directory.Move(destinationPath, movedDestinationPath);
break;
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to move {destinationPath} to {movedDestinationPath} ({e.GetType().Name} {e.Message})");
Console.WriteLine($"!! Please make sure that {destinationPath}, or any of the files inside it, aren't open.");
Console.WriteLine($"!! Press any key to try again, or Ctrl-C to abort the upgrade.");
Console.WriteLine($"!! If you abort the upgrade, none of your files will be modified.");
Console.ReadKey();
}
}
}

Console.WriteLine($"Moving {sourcePath} to {destinationPath}");
Directory.Move(sourcePath, destinationPath);
try
{
Directory.Move(sourcePath, destinationPath);
}
catch (Exception)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to move {sourcePath} to {destinationPath}. Your copy of SyncTrayzor is at {sourcePath}.");
throw;
}

if (destinationExists)
{
var sourceDataFolder = Path.Combine(movedDestinationPath, "data");
var destDataFolder = Path.Combine(destinationPath, "data");
if (Directory.Exists(sourceDataFolder))
{
var destDataFolder = Path.Combine(destinationPath, "data");
Console.WriteLine();
Console.WriteLine($"Copying data folder {sourceDataFolder} to {destDataFolder}...");
DirectoryCopy(sourceDataFolder, destDataFolder);
try
{
DirectoryCopy(sourceDataFolder, destDataFolder);
}
catch (Exception)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to copy {sourceDataFolder} to {destDataFolder}. Your copy of SyncTrayzor is at {movedDestinationPath}, and will still work.");
throw;
}
}
else
{
Console.WriteLine($"Could not find source data folder {sourceDataFolder}, so not copying");
Console.WriteLine();
Console.WriteLine($"!! Could not find source data folder {sourceDataFolder}, so not copying. If you have ever started SyncTrayzor from {movedDestinationPath}, this is an error: please manually copy your 'data' folder from whereever it is to {destDataFolder}");
pauseAtEnd = true;
}

var sourceInstallCount = Path.Combine(movedDestinationPath, "InstallCount.txt");
Expand All @@ -79,16 +130,52 @@ static int Main(string[] args)
{
var installCount = Int32.Parse(File.ReadAllText(sourceInstallCount).Trim());
Console.WriteLine($"Increasing install count to {installCount + 1} from {sourceInstallCount} to {destInstallCount}");
File.WriteAllText(destInstallCount, (installCount + 1).ToString());
try
{
File.WriteAllText(destInstallCount, (installCount + 1).ToString());
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to increase install count: {e.GetType().Name} {e.Message}. Continuing anyway.");
pauseAtEnd = true;
}
}
else
{
Console.WriteLine($"{sourceInstallCount} doesn't exist, so setting installCount to 1 in {destInstallCount}");
File.WriteAllText(destInstallCount, "1");
try
{
File.WriteAllText(destInstallCount, "1");
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to set install count: {e.GetType().Name} {e.Message}. Continuing anyway.");
pauseAtEnd = true;
}
}

Console.WriteLine($"Deleting {movedDestinationPath} (to the recycle bin)");
try
{
RecycleBinDeleter.Delete(movedDestinationPath);
}
catch (Exception e)
{
Console.WriteLine();
Console.WriteLine($"!! Unable to delete your old installation at {movedDestinationPath} ({e.GetType().Name} {e.Message}). Your new installation is at {destinationPath}, and should be fully functional. Please double-check, and manually delete {movedDestinationPath}.");
pauseAtEnd = true;
}
}

Console.WriteLine($"Deleting {movedDestinationPath}");
Directory.Delete(movedDestinationPath, true);
if (pauseAtEnd)
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("One or more warnings occurred. Please review the messages above, and take any appropriate action.");
Console.WriteLine("Press any key to continue (this will restart SyncTrayzor)");
Console.ReadKey();
}

Console.WriteLine($"Restarting application {pathToRestartApplication}");
Expand All @@ -103,6 +190,7 @@ static int Main(string[] args)
Console.WriteLine($"{e.GetType().Name}: {e.Message}");
Console.WriteLine();
Console.WriteLine("The upgrade failed to complete successfully. Sorry about that.");
Console.WriteLine("Please read the messages above.");
Console.WriteLine("Press any key to continue");
Console.ReadKey();
return 2;
Expand All @@ -120,7 +208,7 @@ private static string GenerateBackupDestinationPath(string path)
}
}

throw new Exception("Count not generate a backup path");
throw new Exception("Could not generate a backup path");
}

// From https://msdn.microsoft.com/en-us/library/bb762914%28v=vs.110%29.aspx
Expand All @@ -130,18 +218,12 @@ private static void DirectoryCopy(string sourceDirName, string destDirName)
DirectoryInfo dir = new DirectoryInfo(sourceDirName);

if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDirName}");

DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}

// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
Expand Down
6 changes: 4 additions & 2 deletions src/SyncTrayzor/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@
<target name="debugger" type="Debugger" layout="${time} [${level}] ${logger:shortName=true} ${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
<!-- We want Syncthing output to go to the dedicated log file, and nowhere else -->
<logger name="Syncthing" minlevel="Debug" writeTo="syncthinglogfile" final="true"/>

<logger name="*" minlevel="Debug" writeTo="debugger"/>
<logger name="Syncthing" minlevel="Debug" writeTo="syncthinglogfile"/>
<logger name="*" minlevel="Debug" writeTo="logfile"/>
</rules>
</nlog>

Expand Down
6 changes: 5 additions & 1 deletion src/SyncTrayzor/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ protected override void ConfigureIoC(IStyletIoCBuilder builder)
builder.Bind<IIpcCommsClient>().To<IpcCommsClient>();
builder.Bind<IIpcCommsServer>().To<IpcCommsServer>();
builder.Bind<ISingleApplicationInstanceManager>().To<SingleApplicationInstanceManager>().InSingletonScope();
builder.Bind<IFileWatcherFactory>().To<FileWatcherFactory>();
builder.Bind<IDirectoryWatcherFactory>().To<DirectoryWatcherFactory>();

if (Settings.Default.Variant == SyncTrayzorVariant.Installed)
builder.Bind<IUpdateVariantHandler>().To<InstalledUpdateVariantHandler>();
Expand Down Expand Up @@ -146,6 +148,8 @@ protected override void Configure()
{ MessageBoxResult.OK, Resources.Generic_Dialog_OK },
{ MessageBoxResult.Yes, Resources.Generic_Dialog_Yes },
};

RecycleBinDeleter.Logger = s => LogManager.GetLogger(typeof(RecycleBinDeleter).FullName).Error(s);
}

protected override void Launch()
Expand Down Expand Up @@ -174,7 +178,7 @@ protected override void OnLaunch()

var logger = LogManager.GetCurrentClassLogger();
var assembly = this.Container.Get<IAssemblyProvider>();
logger.Debug("SyncTrazor version {0} ({1}) started at {2}", assembly.FullVersion, assembly.ProcessorArchitecture, assembly.Location);
logger.Debug("SyncTrazor version {0} ({1}) started at {2} (.NET version: {3})", assembly.FullVersion, assembly.ProcessorArchitecture, assembly.Location, DotNetVersionFinder.FindDotNetVersion());

logger.Debug("Cleaning up config folder path");
this.Container.Get<ConfigFolderCleaner>().Clean();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Stylet;
using SyncTrayzor.Services.Conflicts;
using SyncTrayzor.Utils;
using System;
using System.IO;

Expand All @@ -13,6 +14,7 @@ public class ConflictOptionViewModel : PropertyChangedBase

public DateTime DateCreated => this.ConflictOption.Created;
public DateTime LastModified => this.ConflictOption.LastModified;
public string Size => FormatUtils.BytesToHuman(this.ConflictOption.SizeBytes, 1);

public ConflictOptionViewModel(ConflictOption conflictOption)
{
Expand Down
Loading

0 comments on commit b923f0c

Please sign in to comment.