Skip to content

Commit 1a3372a

Browse files
committed
Release 2018.01.03.1
1 parent 0907b95 commit 1a3372a

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace TMF_Simplifier
88
{
99
public class Constants
1010
{
11-
public const string Version = "2018.01.03.0";
11+
public const string Version = "2018.01.03.1";
1212
}
1313
}

MainForm.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ string status
5252
HelpPage Help;
5353
public TMFS()
5454
{
55+
CleanDir(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
5556
InitializeComponent();
5657
if (!Directory.Exists(TotalMinerMain))
5758
{
@@ -401,5 +402,27 @@ private void SettingsBTN_Click(object sender, EventArgs e)
401402
{
402403
SettingsStrip.Visible = !SettingsStrip.Visible;
403404
}
405+
406+
static void CleanDir(string sDir)
407+
{
408+
try
409+
{
410+
foreach (string d in Directory.GetDirectories(sDir))
411+
{
412+
foreach (string f in Directory.GetFiles(d))
413+
{
414+
if(f.EndsWith(".bak"))
415+
{
416+
File.Delete(f);
417+
}
418+
}
419+
CleanDir(d);
420+
}
421+
}
422+
catch (System.Exception excpt)
423+
{
424+
Console.WriteLine(excpt.Message);
425+
}
426+
}
404427
}
405428
}

Updater.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ public static async Task Update()
6262
Release release = await GetLatestRelease();
6363
Asset asset = release.assets.First();
6464
Uri download_uri = new Uri(asset.browser_download_url);
65-
string exe_location = Assembly.GetExecutingAssembly().Location;
66-
string exe_bak_location = exe_location + ".bak";
67-
string extract_location = Path.GetDirectoryName(exe_location);
65+
string extract_location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
6866
string download_location = Path.Combine(extract_location, "download.zip");
6967
await _client.DownloadFileTaskAsync(download_uri, download_location);
70-
if(File.Exists(exe_bak_location))
71-
{
72-
File.Delete(exe_bak_location);
73-
}
74-
File.Move(exe_location, exe_bak_location);
75-
File.Copy(exe_bak_location, exe_location);
7668
using (var tmp = new SevenZipExtractor(download_location))
7769
{
70+
tmp.FileExists += (object sender, FileOverwriteEventArgs e) =>
71+
{
72+
string loc = Path.Combine(extract_location, e.FileName);
73+
string bak = loc + ".bak";
74+
File.Move(loc, bak);
75+
File.Copy(bak, loc);
76+
};
7877
tmp.ExtractArchive(extract_location);
7978
}
8079
File.Delete(download_location);

0 commit comments

Comments
 (0)