Skip to content

Commit f3fa173

Browse files
authored
Merge pull request #559 from emoacht/hotfix
Hotfix
2 parents 482c039 + abdd517 commit f3fa173

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

Source/Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.2"
3+
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.4"
44
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
55
<Package Id="*" InstallerVersion="500" Compressed="yes"
66
InstallScope="perMachine" InstallPrivileges="elevated"

Source/Monitorian.Core/AppKeeper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public AppKeeper()
2121
StartupAgent = new StartupAgent();
2222
}
2323

24-
public Task<bool> StartAsync(StartupEventArgs e) => StartAsync(e, []);
24+
public Task<bool> StartAsync(StartupEventArgs e) => StartAsync(e, null);
2525

2626
public async Task<bool> StartAsync(StartupEventArgs e, IEnumerable<string> additionalOptions)
2727
{
2828
// This method must be called before StandardArguments or OtherArguments property is consumed.
2929
// An exception thrown in this method will not be handled.
30-
await ParseArgumentsAsync(e, EnumerateStandardOptions().Concat(additionalOptions).ToArray());
30+
await ParseArgumentsAsync(e, EnumerateStandardOptions().Concat(additionalOptions ?? []).ToArray());
3131
#if DEBUG
3232
ConsoleService.TryStartWrite();
3333
#else
@@ -99,7 +99,7 @@ private async Task ParseArgumentsAsync(StartupEventArgs e, string[] standardOpti
9999
const char optionMark = '/';
100100
var isStandard = false;
101101

102-
var buffer = args
102+
var buffer = args?
103103
.Where(x => !string.IsNullOrWhiteSpace(x))
104104
.GroupBy(x => (x[0] == optionMark) ? (isStandard = standardOptions.Contains(x.ToLower())) : isStandard)
105105
.ToArray() ?? [];
@@ -113,7 +113,7 @@ private async Task ParseArgumentsAsync(StartupEventArgs e, string[] standardOpti
113113

114114
public Task<string> LoadArgumentsAsync() => AppDataService.ReadAsync(ArgumentsFileName);
115115

116-
public Task SaveArgumentsAsync(string content) => AppDataService.WriteAsync(ArgumentsFileName, false, content);
116+
public Task SaveArgumentsAsync(string content) => AppDataService.WriteAsync(ArgumentsFileName, append: false, delete: true, content);
117117

118118
#endregion
119119

Source/Monitorian.Core/Models/AppDataService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,23 @@ public static async Task<string> ReadAsync(string fileName)
4444
return await sr.ReadToEndAsync();
4545
}
4646

47-
public static async Task WriteAsync(string fileName, bool append, string content)
47+
/// <summary>
48+
/// Asynchronously writes to a specified file.
49+
/// </summary>
50+
/// <param name="fileName">File name to write to</param>
51+
/// <param name="append">True to append to the file; False to overwrite the file</param>
52+
/// <param name="delete">True to delete the file if content is null or empty; False to leave the file</param>
53+
/// <param name="content">Content to write to the file</param>
54+
public static async Task WriteAsync(string fileName, bool append, bool delete, string content)
4855
{
4956
var filePath = Path.Combine(EnsureFolderPath(), fileName);
5057

58+
if (delete && string.IsNullOrEmpty(content))
59+
{
60+
File.Delete(filePath);
61+
return;
62+
}
63+
5164
using var sw = new StreamWriter(filePath, append, Encoding.UTF8); // BOM will be emitted.
5265
await sw.WriteAsync(content);
5366
}

Source/Monitorian.Core/Models/Logger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static async Task<string[]> GetOperationFileNamesAsync()
105105
if (fileNames.Any())
106106
{
107107
content += await AppDataService.ReadAsync(fileNames.First());
108-
await AppDataService.WriteAsync(fileNames.First(), append: false, content);
108+
await AppDataService.WriteAsync(fileNames.First(), append: false, delete: false, content);
109109
AppDataService.Delete(OperationFileName);
110110
}
111111
else
@@ -134,7 +134,7 @@ public static async Task RecordOperationAsync(string content)
134134

135135
try
136136
{
137-
await AppDataService.WriteAsync(fileName, append: true, content);
137+
await AppDataService.WriteAsync(fileName, append: true, delete: false, content);
138138
}
139139
catch (Exception ex)
140140
{

Source/Monitorian.Core/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.6.2.0")]
37-
[assembly: AssemblyFileVersion("4.6.2.0")]
36+
[assembly: AssemblyVersion("4.6.4.0")]
37+
[assembly: AssemblyFileVersion("4.6.4.0")]
3838
[assembly: NeutralResourcesLanguage("en-US")]
3939

4040
// For unit test

Source/Monitorian/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("4.6.2.0")]
55-
[assembly: AssemblyFileVersion("4.6.2.0")]
54+
[assembly: AssemblyVersion("4.6.4.0")]
55+
[assembly: AssemblyFileVersion("4.6.4.0")]
5656
[assembly: Guid("a4cc5362-9b08-465b-ad64-5cfabc72a4c7")]
5757
[assembly: NeutralResourcesLanguage("en-US")]

0 commit comments

Comments
 (0)