Skip to content

Commit 8fbfc22

Browse files
committed
fix: oss upgrade error
1 parent 15f6be8 commit 8fbfc22

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

src/c#/GeneralUpdate.Client/Program.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class Program
1414
{
1515
static async Task Main(string[] args)
1616
{
17-
try
17+
/*try
1818
{
1919
Console.WriteLine($"主程序初始化,{DateTime.Now}!");
2020
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
@@ -57,23 +57,25 @@ static async Task Main(string[] args)
5757
catch (Exception e)
5858
{
5959
Console.WriteLine(e.Message + "\n" + e.StackTrace);
60-
}
60+
}*/
6161

62-
/*var paramsOSS = new GlobalConfigInfoOSS();
63-
paramsOSS.Url = "http://192.168.50.203/versions.json";
64-
paramsOSS.CurrentVersion = "1.0.0.0";
65-
paramsOSS.VersionFileName = "versions.json";
66-
paramsOSS.AppName = "GeneralUpdate.Client.exe";
67-
paramsOSS.Encoding = Encoding.UTF8.WebName;
68-
GeneralClientOSS.Start(paramsOSS);*/
62+
var paramsOSS = new GlobalConfigInfoOSS
63+
{
64+
Url = @"http://localhost:5000/packages/versions.json",
65+
CurrentVersion = "1.0.0.0",
66+
VersionFileName = "versions.json",
67+
AppName = "GeneralUpdate.Client.exe",
68+
Encoding = Encoding.UTF8.WebName
69+
};
70+
await GeneralClientOSS.Start(paramsOSS, "GeneralUpdate.Upgrad.exe");
6971

70-
var hub = new UpgradeHubService("http://localhost:5000/UpgradeHub"
72+
/*var hub = new UpgradeHubService("http://localhost:5000/UpgradeHub"
7173
, null,"dfeb5833-975e-4afb-88f1-6278ee9aeff6");
7274
hub.AddListenerReceive((message) =>
7375
{
7476
Debug.WriteLine(message);
7577
});
76-
await hub.StartAsync();
78+
await hub.StartAsync();*/
7779

7880
/*Task.Run(async () =>
7981
{

src/c#/GeneralUpdate.Common/Compress/ZipCompressionStrategy.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
118118
{
119119
try
120120
{
121-
if (Directory.Exists(unZipDir))
122-
{
123-
StorageManager.DeleteDirectory(unZipDir);
124-
}
125-
Directory.CreateDirectory(unZipDir);
126-
127121
var dirSeparatorChar = Path.DirectorySeparatorChar.ToString();
128122
unZipDir = unZipDir.EndsWith(dirSeparatorChar) ? unZipDir : unZipDir + dirSeparatorChar;
129123

@@ -158,6 +152,13 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
158152
{
159153
greatFolder.Create();
160154
}
155+
156+
if (File.Exists(filePath))
157+
{
158+
File.SetAttributes(filePath, FileAttributes.Normal);
159+
File.Delete(filePath);
160+
}
161+
161162
entries.ExtractToFile(filePath);
162163
}
163164
}

src/c#/GeneralUpdate.Common/Download/DownloadManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public async Task LaunchTasksAsync()
4343
{
4444
var downloadTasks = DownloadTasks.Select(task => task.LaunchAsync()).ToList();
4545
await Task.WhenAll(downloadTasks);
46-
MultiAllDownloadCompleted.Invoke(this, new MultiAllDownloadCompletedEventArgs(true, FailedVersions));
46+
MultiAllDownloadCompleted?.Invoke(this, new MultiAllDownloadCompletedEventArgs(true, FailedVersions));
4747
}
4848
catch (Exception ex)
4949
{
50-
MultiAllDownloadCompleted.Invoke(this, new MultiAllDownloadCompletedEventArgs(false, FailedVersions));
50+
MultiAllDownloadCompleted?.Invoke(this, new MultiAllDownloadCompletedEventArgs(false, FailedVersions));
5151
throw new Exception($"Download manager error: {ex.Message}", ex);
5252
}
5353
}

src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void Decompress(List<VersionOSS> versions)
111111
foreach (var version in versions)
112112
{
113113
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
114-
CompressProvider.Decompress(Format.ZIP,zipFilePath,_appPath, encoding);
114+
CompressProvider.Decompress(Format.ZIP, zipFilePath, _appPath, encoding);
115115
}
116116
}
117117

src/c#/GeneralUpdate.Upgrad/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class Program
1313
{
1414
static async Task Main(string[] args)
1515
{
16-
try
16+
/*try
1717
{
1818
Console.WriteLine($"升级程序初始化,{DateTime.Now}!");
1919
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
@@ -39,7 +39,7 @@ static async Task Main(string[] args)
3939
catch (Exception e)
4040
{
4141
Console.WriteLine(e.Message + "\n" + e.StackTrace);
42-
}
42+
}*/
4343

4444
//中文操作系统的驱动包字段映射表,用于解析所有驱动包的信息的字符串
4545
/*var fieldMappingsCN = new Dictionary<string, string>
@@ -80,7 +80,8 @@ static async Task Main(string[] args)
8080
processor.AddCommand(new InstallDriverCommand(information));
8181
processor.ProcessCommands();*/
8282

83-
//GeneralUpdateOSS.Start();
83+
await GeneralUpdateOSS.Start();
84+
8485
while (true)
8586
{
8687
var input = Console.ReadLine();

0 commit comments

Comments
 (0)