Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from adrianmteo/develop
Browse files Browse the repository at this point in the history
Fix auto updater cached file after update
  • Loading branch information
adrianmteo authored Mar 20, 2020
2 parents 7b2c726 + dc2ba12 commit d8671f4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Luna/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: Guid("7FDBD0F5-0E11-4048-8C62-A5F64BB878AF")]
12 changes: 12 additions & 0 deletions Luna/Utils/AutoFileSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ public void ReloadFromDisk()
}
}

public void DeleteFromDisk()
{
try
{
File.Delete(Path);
}
catch (Exception ex)
{
Logger.Error(ex.Message);
}
}

private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (ReadOnly)
Expand Down
10 changes: 9 additions & 1 deletion Luna/Utils/AutoUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Luna.Models;
using Luna.Utils.Logger;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -55,7 +56,9 @@ public AutoUpdater(bool autoUpdate = false, bool noStart = false)
AutoUpdate = autoUpdate;
NoStart = noStart;

if (Model.Status == UpdateStatus.Checking || Model.Status == UpdateStatus.Downloading || Model.Status == UpdateStatus.Error)
List<UpdateStatus> resetStatuses = new List<UpdateStatus>() { UpdateStatus.Checking, UpdateStatus.Downloading, UpdateStatus.Error };

if (resetStatuses.Contains(Model.Status))
{
Model.Status = UpdateStatus.None;
}
Expand Down Expand Up @@ -169,9 +172,14 @@ public void InstallUpdate()
if (!File.Exists(Model.DownloadPath))
{
Logger.Warning("Update file was not found at '{0}'", Model.DownloadPath);

Model.Status = UpdateStatus.Error;

return;
}

_autoSaver.DeleteFromDisk();

Logger.Info("Staring update file at '{0}'", Model.DownloadPath);

try
Expand Down
8 changes: 2 additions & 6 deletions Luna/Windows/UpdateWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="NoUpdateTemplate">
<Label Padding="0">
<TextBlock>
No new updates found. Last check was <Run Text="{Binding LastCheck}" />.
</TextBlock>
</Label>
<Label Padding="0" Content="No new updates found" />
</DataTemplate>
<DataTemplate x:Key="NewUpdateTemplate">
<StackPanel>
Expand Down Expand Up @@ -66,7 +62,7 @@
</DataTemplate>
<DataTemplate x:Key="ErrorView">
<StackPanel>
<Label Content="An error has occured. Check logs" />
<Label Content="An error has occured. Please check logs for more info." />
<Button Content="Try Again" HorizontalAlignment="Right" Click="CheckButton_Click" />
</StackPanel>
</DataTemplate>
Expand Down

0 comments on commit d8671f4

Please sign in to comment.