From 19e3d3df2b20cdc22e092a0ea6d5a3232583ddb3 Mon Sep 17 00:00:00 2001 From: "Juster.zhu" Date: Thu, 6 Oct 2022 18:21:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E9=87=8D?= =?UTF-8?q?=E5=90=8D=E7=9A=84patch=E8=A1=A5=E4=B8=81=E7=9B=B8=E4=BA=92?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c#/GeneralUpdate.Client/MainPage.xaml.cs | 3 ++ .../DifferentialCore.cs | 10 +++++-- .../DataServices/Http/HttpService.cs | 3 +- .../Services/MainService.cs | 4 +-- .../ViewModels/MainViewModel.cs | 28 +++++++++++++++---- src/c#/GeneralUpdate.Zip/GeneralZipFactory.cs | 11 ++++++-- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/c#/GeneralUpdate.Client/MainPage.xaml.cs b/src/c#/GeneralUpdate.Client/MainPage.xaml.cs index d7f13ef..fa47991 100644 --- a/src/c#/GeneralUpdate.Client/MainPage.xaml.cs +++ b/src/c#/GeneralUpdate.Client/MainPage.xaml.cs @@ -3,6 +3,9 @@ using GeneralUpdate.ClientCore.Hubs; using GeneralUpdate.Core.Bootstrap; using GeneralUpdate.Core.Domain.Entity; using GeneralUpdate.Core.Domain.Enum; +using GeneralUpdate.Core.Strategys.PlatformAndroid; +using GeneralUpdate.Core.Strategys.PlatformiOS; +using GeneralUpdate.Core.Strategys.PlatformMac; using GeneralUpdate.Core.Strategys.PlatformWindows; using System.Text; diff --git a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs index 1aa90f4..30076e7 100644 --- a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs +++ b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs @@ -88,13 +88,13 @@ namespace GeneralUpdate.Differential if (string.IsNullOrEmpty(tempPath)) { tempDir = patchPath; - tempPath0 = Path.Combine(patchPath, $"{Path.GetFileNameWithoutExtension(file.Name)}{PATCH_FORMAT}"); + tempPath0 = Path.Combine(patchPath, $"{file.Name}{PATCH_FORMAT}"); } else { tempDir = Path.Combine(patchPath, tempPath); if (!Directory.Exists(tempDir)) Directory.CreateDirectory(tempDir); - tempPath0 = Path.Combine(tempDir, $"{Path.GetFileNameWithoutExtension(file.Name)}{PATCH_FORMAT}"); + tempPath0 = Path.Combine(tempDir, $"{file.Name}{PATCH_FORMAT}"); } var finOldFile = nodes.Item1.FirstOrDefault(i => i.Name.Equals(file.Name)); var oldfile = finOldFile == null ? "" : finOldFile.FullName; @@ -143,7 +143,11 @@ namespace GeneralUpdate.Differential foreach (var oldFile in oldFiles) { //Only the difference file (.patch) can be updated here. - var findFile = patchFiles.FirstOrDefault(f => Path.GetFileNameWithoutExtension(f.Name).Equals(Path.GetFileNameWithoutExtension(oldFile.Name))); + var findFile = patchFiles.FirstOrDefault(f => + { + var tempName = Path.GetFileNameWithoutExtension(f.Name).Replace(PATCH_FORMAT, ""); + return tempName.Equals(oldFile.Name); + }); if (findFile != null) { var extensionName = Path.GetExtension(findFile.FullName); diff --git a/src/c#/GeneralUpdate.Infrastructure/DataServices/Http/HttpService.cs b/src/c#/GeneralUpdate.Infrastructure/DataServices/Http/HttpService.cs index 09f5fbe..fdb6563 100644 --- a/src/c#/GeneralUpdate.Infrastructure/DataServices/Http/HttpService.cs +++ b/src/c#/GeneralUpdate.Infrastructure/DataServices/Http/HttpService.cs @@ -24,7 +24,7 @@ namespace GeneralUpdate.Infrastructure.DataServices.Http } } - public async Task PostFileRequest(string url, Dictionary parameters, string filePath , Action reponseCallback, int timeOutInMillisecond = 1000 * 10) where T : class + public async Task PostFileRequest(string url, Dictionary parameters, string filePath , Action reponseCallback) where T : class { try { @@ -34,7 +34,6 @@ namespace GeneralUpdate.Infrastructure.DataServices.Http fileStream.Read(bytes, 0, bytes.Length); using (var client = new HttpClient()) { - client.Timeout = new TimeSpan(timeOutInMillisecond); var message = new HttpRequestMessage(HttpMethod.Post, url); message.Content = MultipartFormDataContentProvider.CreateContent(bytes,Path.GetFileName(filePath), parameters); var responseMessage = await client.SendAsync(message); diff --git a/src/c#/GeneralUpdate.PacketTool/Services/MainService.cs b/src/c#/GeneralUpdate.PacketTool/Services/MainService.cs index 16b9c18..43cf19e 100644 --- a/src/c#/GeneralUpdate.PacketTool/Services/MainService.cs +++ b/src/c#/GeneralUpdate.PacketTool/Services/MainService.cs @@ -4,9 +4,9 @@ namespace GeneralUpdate.PacketTool.Services { public class MainService { - public async Task PostUpgradPakcet(string filePath, int clientType, string version, string clientAppKey,string md5,Action reponseCallback) where T : class + public async Task PostUpgradPakcet(string remoteUrl, string filePath, int clientType, string version, string clientAppKey,string md5,Action reponseCallback) where T : class { - var remoteUrl = "http://127.0.0.1:5001/upload"; + if(string.IsNullOrEmpty(remoteUrl)) remoteUrl = "http://127.0.0.1:5001/upload"; var parameters = new Dictionary(); parameters.Add("clientType", clientType.ToString()); parameters.Add("version", version); diff --git a/src/c#/GeneralUpdate.PacketTool/ViewModels/MainViewModel.cs b/src/c#/GeneralUpdate.PacketTool/ViewModels/MainViewModel.cs index a7f492c..5941ed2 100644 --- a/src/c#/GeneralUpdate.PacketTool/ViewModels/MainViewModel.cs +++ b/src/c#/GeneralUpdate.PacketTool/ViewModels/MainViewModel.cs @@ -80,8 +80,8 @@ namespace GeneralUpdate.PacketTool.ViewModels if (_formats == null) { _formats = new List(); - _formats.Add("ZIP"); - _formats.Add("7Z"); + _formats.Add(".zip"); + _formats.Add(".7z"); } return _formats; } @@ -178,12 +178,24 @@ namespace GeneralUpdate.PacketTool.ViewModels { await DifferentialCore.Instance.Clean(SourcePath, TargetPath, PatchPath, (sender, args) =>{}, String2OperationType(CurrentFormat),String2Encoding(CurrentEncoding), PacketName); + + await DifferentialCore.Instance.Drity(SourcePath,PatchPath); if (IsPublish) { - var packetPath = Path.Combine(TargetPath,PacketName); - if (!File.Exists(packetPath)) await Shell.Current.DisplayAlert("Build options", $"The package was not found in the following path {packetPath} !", "cancel"); - await _mainService.PostUpgradPakcet(packetPath, String2AppType(CurrnetAppType), CurrentVersion,CurrentClientAppKey,"", async (resp) => + var packetPath = Path.Combine(TargetPath,$"{PacketName}{CurrentFormat}"); + if (!File.Exists(packetPath)) + { + await Shell.Current.DisplayAlert("Build options", $"The package was not found in the following path {packetPath} !", "cancel"); + return; + } + await _mainService.PostUpgradPakcet(Url,packetPath, String2AppType(CurrnetAppType), CurrentVersion,CurrentClientAppKey,"", async (resp) => { + if (resp == null) + { + await Shell.Current.DisplayAlert("Build options", "Upload failed !", "cancel"); + return; + } + if (resp.Code == HttpStatus.OK) { await Shell.Current.DisplayAlert("Build options", resp.Message, "ok"); @@ -194,10 +206,14 @@ namespace GeneralUpdate.PacketTool.ViewModels } }); } + else + { + await Shell.Current.DisplayAlert("Build options", "Build complete.", "ok"); + } } catch (Exception ex) { - await Shell.Current.DisplayAlert("Build options", $"Operation failed : {TargetPath} , Error : {ex.Message} !", "ok"); + await Shell.Current.DisplayAlert("Build options", $"Operation failed : {TargetPath} , Error : {ex.Message} !", "cancel"); } } diff --git a/src/c#/GeneralUpdate.Zip/GeneralZipFactory.cs b/src/c#/GeneralUpdate.Zip/GeneralZipFactory.cs index 78ea828..02b34f2 100644 --- a/src/c#/GeneralUpdate.Zip/GeneralZipFactory.cs +++ b/src/c#/GeneralUpdate.Zip/GeneralZipFactory.cs @@ -27,10 +27,17 @@ namespace GeneralUpdate.Zip public event CompressProgressEventHandler CompressProgress; /// - /// Select archive format . + /// Configuring Compression. /// - /// + /// Enumeration selects the compressed package format to operate on.(OperationType.GZip , OperationType.G7z) + /// Compressed package Name. + /// Source file path. + /// The target path. + /// Whether to include the root directory when packing. + /// Compressed package encoding format. /// + /// + /// public IFactory CreatefOperate(OperationType type,string name, string sourcePath, string destinationPath, bool includeBaseDirectory = false, Encoding encoding = null) { if (string.IsNullOrWhiteSpace(sourcePath) || string.IsNullOrWhiteSpace(destinationPath)) -- Gitee