Skip to content

Commit

Permalink
oss add delete packet
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Jan 4, 2025
1 parent 3c16a01 commit 77f648a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/c#/GeneralUpdate.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class Program
{
static async Task Main(string[] args)
{
/*try
try
{
Console.WriteLine($"主程序初始化,{DateTime.Now}!");
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
Expand Down Expand Up @@ -57,17 +57,17 @@ static async Task Main(string[] args)
catch (Exception e)
{
Console.WriteLine(e.Message + "\n" + e.StackTrace);
}*/
}

var paramsOSS = new GlobalConfigInfoOSS
/*var paramsOSS = new GlobalConfigInfoOSS
{
Url = @"http://localhost:5000/packages/versions.json",
CurrentVersion = "1.0.0.0",
VersionFileName = "versions.json",
AppName = "GeneralUpdate.Client.exe",
Encoding = Encoding.UTF8.WebName
};
await GeneralClientOSS.Start(paramsOSS, "GeneralUpdate.Upgrad.exe");
await GeneralClientOSS.Start(paramsOSS, "GeneralUpdate.Upgrad.exe");*/

/*var hub = new UpgradeHubService("http://localhost:5000/UpgradeHub"
, null,"dfeb5833-975e-4afb-88f1-6278ee9aeff6");
Expand Down
17 changes: 15 additions & 2 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientOSS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ private static bool IsUpgrade(string clientVersion, string serverVersion)

private static void DownloadFile(string url, string path)
{
using var webClient = new WebClient();
webClient.DownloadFile(new Uri(url), path);
try
{
if (File.Exists(path))
{
File.SetAttributes(path, FileAttributes.Normal);
File.Delete(path);
}

using var webClient = new WebClient();
webClient.DownloadFile(new Uri(url), path);
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
}
17 changes: 15 additions & 2 deletions src/c#/GeneralUpdate.Core/Strategys/OSSStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public async Task ExecuteAsync()
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
throw new Exception(ex.Message + "\n" + ex.StackTrace);
}
finally
Expand Down Expand Up @@ -90,6 +91,7 @@ private async Task DownloadVersions(List<VersionOSS> versions)
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
throw new Exception(e.Message + "\n" + e.StackTrace);
}
}
Expand All @@ -110,8 +112,19 @@ private void Decompress(List<VersionOSS> versions)
var encoding = Encoding.GetEncoding(_parameter.Encoding);
foreach (var version in versions)
{
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
CompressProvider.Decompress(Format.ZIP, zipFilePath, _appPath, encoding);
try
{
var zipFilePath = Path.Combine(_appPath, $"{version.PacketName}{Format.ZIP}");
CompressProvider.Decompress(Format.ZIP, zipFilePath, _appPath, encoding);

if (!File.Exists(zipFilePath)) continue;
File.SetAttributes(zipFilePath, FileAttributes.Normal);
File.Delete(zipFilePath);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/c#/GeneralUpdate.Upgrad/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class Program
{
static async Task Main(string[] args)
{
/*try
try
{
Console.WriteLine($"升级程序初始化,{DateTime.Now}!");
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
Expand All @@ -39,7 +39,7 @@ static async Task Main(string[] args)
catch (Exception e)
{
Console.WriteLine(e.Message + "\n" + e.StackTrace);
}*/
}

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

await GeneralUpdateOSS.Start();
//await GeneralUpdateOSS.Start();

while (true)
{
Expand Down

0 comments on commit 77f648a

Please sign in to comment.