Skip to content

Commit dc0391c

Browse files
committed
1.9.10
- AutoUpdate fixes
1 parent 6e357b4 commit dc0391c

File tree

6 files changed

+73
-46
lines changed

6 files changed

+73
-46
lines changed

Source/AutoActions.Updater/Program.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,29 @@ class Program
1616

1717
static void Main(string[] args)
1818
{
19-
System.Threading.Thread.Sleep(20000);
20-
UpdateData updateData = new UpdateData();
21-
updateData.SaveUpdateData("D:\\UpdateData.json");
2219
temporaryFolder = GetTemporaryDirectory();
20+
Console.WriteLine("AutoActions Updater");
21+
Console.WriteLine("");
22+
Console.WriteLine("");
23+
Console.WriteLine("Updating AutoActions...");
2324
try
2425
{
2526
bool download = bool.Parse(args[0]);
2627
string zip = GetZip(download, args[1]);
2728
string targetFolder = args[2];
2829
string callingProcess = args[3];
2930
Update(zip, targetFolder, callingProcess);
31+
Console.WriteLine($"Starting {callingProcess}...");
32+
System.Threading.Thread.Sleep(2000);
3033
Process.Start(Path.Combine(targetFolder, $"{callingProcess}.exe"));
3134

3235
}
33-
36+
catch (Exception ex)
37+
{
38+
Console.WriteLine(ex.ToString());
39+
Console.WriteLine("Press any key to close this window.");
40+
Console.ReadKey();
41+
}
3442

3543
finally
3644
{
@@ -44,12 +52,14 @@ private static string GetZip(bool download, string path)
4452
string updateZip = Path.Combine(temporaryFolder, "Update.zip");
4553
if (download)
4654
{
47-
updateZip = Path.Combine(temporaryFolder, "Update.zip");
55+
Console.WriteLine($"Downloading from {path}...");
4856
using (WebClient myWebClient = new WebClient())
4957
{
5058
// Download the Web resource and save it into the current filesystem folder.
5159
myWebClient.DownloadFile(path, updateZip);
5260
}
61+
Console.WriteLine($"Finished download.");
62+
5363
}
5464
else
5565
File.Copy(path, updateZip, true);
@@ -58,8 +68,9 @@ private static string GetZip(bool download, string path)
5868

5969
private static void Update(string zip, string targetFolder, string callingProcess)
6070
{
61-
System.Threading.Thread.Sleep(2000);
71+
System.Threading.Thread.Sleep(1000);
6272
ZipFile.ExtractToDirectory(zip, temporaryFolder);
73+
Console.WriteLine($"Extrating zip to {temporaryFolder}...");
6374
File.Delete(zip);
6475
UpdateData updateData = UpdateData.LoadFromFile(Path.Combine(temporaryFolder, "UpdateData.json"));
6576
Process[] processes = Process.GetProcessesByName(callingProcess);
@@ -73,16 +84,24 @@ private static void Update(string zip, string targetFolder, string callingProces
7384
filesToCopy.Remove(Path.Combine(temporaryFolder, "AutoActions.Updater.exe"));
7485
if (filesToCopy.Contains(Path.Combine(temporaryFolder, "AutoActions.Updater.pdb")))
7586
filesToCopy.Remove(Path.Combine(temporaryFolder, "AutoActions.Updater.pdb"));
87+
Console.WriteLine($"Updating files...");
88+
7689
foreach (string file in filesToCopy)
7790
{
91+
7892
string targetFileName = Path.Combine(targetFolder, Path.GetFileName(file));
93+
Console.WriteLine($"Updating {targetFileName}");
7994
if (File.Exists(targetFileName))
8095
File.Delete(targetFileName);
8196
File.Move(file, targetFileName);
8297
}
98+
if (updateData.FilesToDelete.Count > 0)
99+
Console.WriteLine($"Removing files files...");
100+
83101
foreach (string file in updateData.FilesToDelete)
84102
{
85103
string targetFileName = Path.Combine(targetFolder, Path.GetFileName(file));
104+
Console.WriteLine($"Removing {targetFileName}");
86105
if (File.Exists(targetFileName))
87106
File.Delete(targetFileName);
88107
}

Source/AutoActions/AutoActions.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
126126
<HintPath>..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll</HintPath>
127127
</Reference>
128-
<Reference Include="System.Net.Http" />
129128
<Reference Include="System.Numerics" />
130129
<Reference Include="System.Runtime.Serialization" />
131130
<Reference Include="System.Runtime.Serialization.Primitives, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -436,14 +435,14 @@
436435
<PropertyGroup>
437436
<PostBuildEvent>if $(ConfigurationName) == Release (
438437
del "$(TargetName).exe.config"
439-
del "$(TargetName).exe.config"
440438
)</PostBuildEvent>
441439
</PropertyGroup>
442440
<PropertyGroup>
443441
<PreBuildEvent>$(SolutionDir)\BuildTools\XamlDictionaryMergeTool\XamlDictionaryMergeTool.exe "$(ProjectDir)Controls" "$(ProjectDir)Controls\AppResources.xaml"
444-
copy /Y "$(SolutionDir)Externals\$(PlatformName)\HDRController.dll" "$(OutDir)HDRController.dll"
442+
445443
if $(ConfigurationName) == Release (
446444
rd "$(TargetDir)" /s /q
445+
copy /Y "$(SolutionDir)Externals\$(PlatformName)\HDRController.dll" "$(OutDir)HDRController.dll"
447446
)
448447
</PreBuildEvent>
449448
</PropertyGroup>

Source/AutoActions/AutoActionsDaemon.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ public Version Version
9595

9696
public AutoActionsDaemon()
9797
{
98-
//ChangeLanguage( new System.Globalization.CultureInfo("en-US"));
98+
//ChangeLanguage( new System.Globalization.CultureInfo("en-US"));
9999
Application.Current.Exit += Current_Exit;
100100
Initialize();
101+
101102
}
102103

103104
private void ChangeLanguage(CultureInfo culture)
@@ -125,8 +126,10 @@ private void Initialize()
125126
_lastActions = new ObservableCollection<IProfileAction>();
126127
InitializeApplicationWatcher();
127128
LoadSettings();
129+
SplashScreen splashScreen = new SplashScreen("SplashScreen.png");
130+
if (!Settings.StartMinimizedToTray)
131+
splashScreen.Show(true);
128132
Globals.Logs.Add("Initializing...", false);
129-
130133
if (Settings.CheckForNewVersion)
131134
Globals.Instance.CheckForNewVersion();
132135
InitializeDisplayManager();
@@ -138,6 +141,8 @@ private void Initialize()
138141
Initialized = true;
139142
Globals.Logs.Add("Initialized", false);
140143
Start();
144+
if (!Settings.StartMinimizedToTray)
145+
splashScreen.Close(new TimeSpan(0, 0, 0, 2));
141146
}
142147
catch (Exception ex)
143148
{

Source/AutoActions/Globals.cs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,33 @@ public void LoadSettings()
100100
public void CheckForNewVersion()
101101
{
102102

103-
Globals.Logs.Add($"Checking for new version...", false);
104-
105-
GitHubData data = GitHubIntegration.GetGitHubData();
106-
Version localVersion = VersionExtension.ApplicationVersion(System.Reflection.Assembly.GetExecutingAssembly());
107-
int versionComparison = localVersion.CompareTo(data.CurrentVersion);
108-
if (versionComparison < 0)
109-
{
110-
Globals.Logs.Add($"Newer version availabe.", false);
111-
if (Settings.AutoUpdate)
112-
AutoUpdate(data);
113-
else
114-
Application.Current.Dispatcher.Invoke(
115-
(Action)(() =>
116-
{
117-
ShowInfo(data);
118-
}));
119-
}
103+
Globals.Logs.Add($"Checking for new version...", false);
104+
GitHubData data = null;
105+
try
106+
{
107+
data = GitHubIntegration.GetGitHubData();
108+
}
109+
catch (Exception ex)
110+
{
111+
Globals.Logs.AddException(ex);
112+
return;
113+
}
114+
Version localVersion = VersionExtension.ApplicationVersion(System.Reflection.Assembly.GetExecutingAssembly());
115+
int versionComparison = localVersion.CompareTo(data.CurrentVersion);
116+
if (versionComparison < 0)
117+
{
118+
Globals.Logs.Add($"Newer version availabe.", false);
119+
if (Settings.AutoUpdate)
120+
AutoUpdate(data);
120121
else
121-
Globals.Logs.Add($"Local version is up to date.", false);
122+
Application.Current.Dispatcher.Invoke(
123+
(Action)(() =>
124+
{
125+
ShowInfo(data);
126+
}));
127+
}
128+
else
129+
Globals.Logs.Add($"Local version is up to date.", false);
122130

123131
}
124132

Source/AutoActions/Info/Github/GitHubIntegration.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace AutoActions.Info.Github
1010
{
1111
public static class GitHubIntegration
1212
{
13-
private static GitHubClient _client = new GitHubClient(new ProductHeaderValue("AutoActions"));
13+
private static GitHubClient _client = null;
1414

1515
private static bool Initialized = false;
1616
private static void InitializeClient()
@@ -26,19 +26,18 @@ public static GitHubData GetGitHubData()
2626
{
2727
InitializeClient();
2828
Globals.Logs.Add($"Requesting releases...", false);
29-
IReadOnlyList<Release> releases;
29+
Release release;
3030
try
3131
{
32-
releases = _client.Repository.Release.GetAll("Codectory", "AutoActions").Result;
33-
32+
release = _client.Repository.Release.GetLatest("Codectory", "AutoHDR").Result;
3433
}
35-
catch (Exception)
34+
catch (Exception ex)
3635
{
37-
releases = _client.Repository.Release.GetAll("Codectory", "AutoHDR").Result;
36+
release = _client.Repository.Release.GetLatest("Codectory", "AutoActions").Result;
3837
}
39-
Version latestGitHubVersion = new Version(releases[0].TagName);
40-
DateTime latestReleaseDate = releases[0].PublishedAt.HasValue ? releases[0].PublishedAt.Value.DateTime : DateTime.MinValue;
41-
Globals.Logs.Add($"Releases found: {releases.Count} Latest version: {latestGitHubVersion}", false);
38+
Version latestGitHubVersion = new Version(release.TagName);
39+
DateTime latestReleaseDate = release.PublishedAt.HasValue ? release.PublishedAt.Value.DateTime : DateTime.MinValue;
40+
Globals.Logs.Add($"Releases found. Latest version: {latestGitHubVersion}", false);
4241

4342
List<string> sourceForgeAdditions = new List<string>()
4443
{
@@ -54,10 +53,8 @@ public static GitHubData GetGitHubData()
5453
};
5554

5655
string changelog = string.Empty;
57-
Globals.Logs.Add($"Building changelog...", false);
5856

59-
foreach (Release release in releases)
60-
{
57+
6158
if (!string.IsNullOrEmpty(changelog))
6259
changelog += "\r\n\r\n\r\n\r\n";
6360
string releaseChangelog = release.Body;
@@ -69,10 +66,9 @@ public static GitHubData GetGitHubData()
6966
}
7067

7168
changelog += $"[{release.TagName}]\r\n\r\n{releaseChangelog}";
72-
}
7369
Globals.Logs.Add($"Creating GitHubData...", false);
74-
var assetx64 = releases[0].Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains("_X64"));
75-
var assetx86 = releases[0].Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains("_X86"));
70+
var assetx64 = release.Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains("_X64"));
71+
var assetx86 = release.Assets.FirstOrDefault(a => a.Name.ToUpperInvariant().Contains("_X86"));
7672
return new GitHubData(changelog, latestGitHubVersion, latestReleaseDate, $@"https://github.com/Codectory/AutoActions/releases/tag/{latestGitHubVersion}", assetx64 != null ? assetx64.BrowserDownloadUrl : "", assetx86 != null ? assetx86.BrowserDownloadUrl : "");
7773
}
7874
}

Source/AutoActions/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.9.9.0")]
56-
[assembly: AssemblyFileVersion("1.9.9.0")]
55+
[assembly: AssemblyVersion("1.9.10.0")]
56+
[assembly: AssemblyFileVersion("1.9.10.0")]

0 commit comments

Comments
 (0)