Skip to content

Commit

Permalink
Revert build
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 18, 2016
1 parent bc561ce commit 00f2be2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
16 changes: 8 additions & 8 deletions UpdateWatcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace UpdateWatcher
/// </summary>
public partial class App : Application
{
public event EventHandler OnWorkStarted;
public event EventHandler OnWorkCompleted;
public event EventHandler OnTick;

Expand Down Expand Up @@ -63,11 +64,6 @@ private void Initialize(object sender, StartupEventArgs startupEventArgs)

BuildsManager.UpdateInfo(Settings.DownloadFolder);

if (BuildsManager.LastBuild()?.FullPath != Settings.LastFileData?.FullPath)
Settings.LastFileData = null;

RevertBuild();
Config.Save();

DownloadManager = new DownloadManager(Config.Data.DownloadFolder);

Expand All @@ -85,6 +81,10 @@ private void Initialize(object sender, StartupEventArgs startupEventArgs)
MainWindow = new MainWindow();
MainWindow.Show();

OnWorkStarted?.Invoke(this, null);
RevertBuild();
Config.Save();
OnWorkCompleted?.Invoke(this, null);


}
Expand Down Expand Up @@ -186,10 +186,10 @@ private void OnDownloadDataCompleted(FileInfo info)

private void CheckIgnore(FileInfo info)
{
if (BuildsManager.IsIgnored(info.FullName))
if (BuildsManager.IsIgnored(info.Name))
Logger.Debug($"CheckIgnore Manager :: This build marked as ignored {info.Name}, Size: {info.Length}, skipping");

if (!BuildsManager.IsIgnored(info.FullName) && Settings.LastFileData?.FullPath != info.FullName)
if (!BuildsManager.IsIgnored(info.Name) && Settings.LastFileData?.FullPath != info.FullName)
{
Settings.LastFileData = new FileData(info);

Expand Down Expand Up @@ -344,7 +344,7 @@ public void Save()
private void RevertBuild()
{
if (Settings.LastFileData == null) return;
if (BuildsManager.IsIgnored(Settings.LastFileData.FullPath))
if (BuildsManager.IsIgnored(Settings.LastFileData.FileName))
{
Logger.Debug($"RevertBuild Manager :: Current build [{Settings.LastFileData.FileName}] marked as ignored, will try revert previous if have one");

Expand Down
6 changes: 6 additions & 0 deletions UpdateWatcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public MainWindow()
Application.Current.Exit += Current_Exit;

((App)App.Current).OnWorkCompleted += OnWorkCompleted;
((App)App.Current).OnWorkStarted += OnWorkStarted;
((App)App.Current).OnTick += OnTick;
((App)App.Current).OnTick += OnTick;

Expand Down Expand Up @@ -160,6 +161,11 @@ private void BtnStart_OnClick(object sender, RoutedEventArgs e)
((App)App.Current).Download();

}
private void OnWorkStarted(object sender, EventArgs e)
{
OnStarted();
}


private void OnStarted()
{
Expand Down
4 changes: 2 additions & 2 deletions UpdateWatcher/Managers/BuildsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void UpdateInfo(string buildsFolder)

}

public bool IsIgnored(string fullPath) => Builds.Any(b => b.Ignore && b.FullPath == fullPath);
public IBuildData LastBuild() => Builds.OrderByDescending(b =>
public bool IsIgnored(string fileName) => Builds.Any(b => b.Ignore && b.FileName == fileName);
public IBuildData LastBuild() => Builds.Where(b=> !b.Ignore).OrderByDescending(b =>
{
var version = VersionParser.Parse(new FileInfo(b.FullPath).Name);
if (string.IsNullOrWhiteSpace(version)) version = "0.0";
Expand Down
4 changes: 2 additions & 2 deletions UpdateWatcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
//
// Можно задать все значения или принять номер построения и номер редакции по умолчанию,
// используя "*", как показано ниже:
[assembly: AssemblyVersion("1.1.42.0906")]
[assembly: AssemblyInformationalVersion("Build date: 2016-09-18 09:06:53; Revision date: 2016-09-18 09:06:50; Revision(s) in working copy: 8:42.")]
[assembly: AssemblyVersion("1.1.43.0928")]
[assembly: AssemblyInformationalVersion("Build date: 2016-09-18 09:28:13; Revision date: 2016-09-18 09:28:11; Revision(s) in working copy: 8:43.")]

0 comments on commit 00f2be2

Please sign in to comment.