Skip to content

Commit 77f648a

Browse files
committed
oss add delete packet
1 parent 3c16a01 commit 77f648a

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

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

Lines changed: 4 additions & 4 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,17 +57,17 @@ 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
62+
/*var paramsOSS = new GlobalConfigInfoOSS
6363
{
6464
Url = @"http://localhost:5000/packages/versions.json",
6565
CurrentVersion = "1.0.0.0",
6666
VersionFileName = "versions.json",
6767
AppName = "GeneralUpdate.Client.exe",
6868
Encoding = Encoding.UTF8.WebName
6969
};
70-
await GeneralClientOSS.Start(paramsOSS, "GeneralUpdate.Upgrad.exe");
70+
await GeneralClientOSS.Start(paramsOSS, "GeneralUpdate.Upgrad.exe");*/
7171

7272
/*var hub = new UpgradeHubService("http://localhost:5000/UpgradeHub"
7373
, null,"dfeb5833-975e-4afb-88f1-6278ee9aeff6");

src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,20 @@ private static bool IsUpgrade(string clientVersion, string serverVersion)
8080

8181
private static void DownloadFile(string url, string path)
8282
{
83-
using var webClient = new WebClient();
84-
webClient.DownloadFile(new Uri(url), path);
83+
try
84+
{
85+
if (File.Exists(path))
86+
{
87+
File.SetAttributes(path, FileAttributes.Normal);
88+
File.Delete(path);
89+
}
90+
91+
using var webClient = new WebClient();
92+
webClient.DownloadFile(new Uri(url), path);
93+
}
94+
catch (Exception e)
95+
{
96+
Debug.WriteLine(e);
97+
}
8598
}
8699
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public async Task ExecuteAsync()
5252
}
5353
catch (Exception ex)
5454
{
55+
Debug.WriteLine(ex.Message);
5556
throw new Exception(ex.Message + "\n" + ex.StackTrace);
5657
}
5758
finally
@@ -90,6 +91,7 @@ private async Task DownloadVersions(List<VersionOSS> versions)
9091
}
9192
catch (Exception e)
9293
{
94+
Debug.WriteLine(e.Message);
9395
throw new Exception(e.Message + "\n" + e.StackTrace);
9496
}
9597
}
@@ -110,8 +112,19 @@ private void Decompress(List<VersionOSS> versions)
110112
var encoding = Encoding.GetEncoding(_parameter.Encoding);
111113
foreach (var version in versions)
112114
{
113-
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
114-
CompressProvider.Decompress(Format.ZIP, zipFilePath, _appPath, encoding);
115+
try
116+
{
117+
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
118+
CompressProvider.Decompress(Format.ZIP, zipFilePath, _appPath, encoding);
119+
120+
if (!File.Exists(zipFilePath)) continue;
121+
File.SetAttributes(zipFilePath, FileAttributes.Normal);
122+
File.Delete(zipFilePath);
123+
}
124+
catch (Exception e)
125+
{
126+
Debug.WriteLine(e.Message);
127+
}
115128
}
116129
}
117130

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

Lines changed: 3 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,7 @@ static async Task Main(string[] args)
8080
processor.AddCommand(new InstallDriverCommand(information));
8181
processor.ProcessCommands();*/
8282

83-
await GeneralUpdateOSS.Start();
83+
//await GeneralUpdateOSS.Start();
8484

8585
while (true)
8686
{

0 commit comments

Comments
 (0)