From 90da93353657135664c97c0cc739199df835ca77 Mon Sep 17 00:00:00 2001 From: Juster Zhu Date: Thu, 28 Dec 2023 21:31:25 +0800 Subject: [PATCH] fix: Identify bugs that require files to be deleted --- src/c#/GeneralUpdate.Client/MySample.cs | 8 ++++++++ src/c#/GeneralUpdate.Client/Program.cs | 3 ++- .../ContentProvider/FileProvider.cs | 17 +++-------------- .../DifferentialCore.cs | 2 -- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs index cdd6a171..26f4fde7 100644 --- a/src/c#/GeneralUpdate.Client/MySample.cs +++ b/src/c#/GeneralUpdate.Client/MySample.cs @@ -11,6 +11,7 @@ using GeneralUpdate.Core.Domain.Enum; using GeneralUpdate.Core.Events.CommonArgs; using GeneralUpdate.Differential; +using System.IO; namespace GeneralUpdate.Client { @@ -225,6 +226,13 @@ public async Task TestDifferentialClean() await DifferentialCore.Instance.Clean(path1, path2, path3); } + public async Task TestDifferentialDirty() + { + var path1 = "D:\\packet\\source"; + var path2 = "D:\\packet\\patchs"; + await DifferentialCore.Instance.Dirty(path1, path2); + } + #endregion } } diff --git a/src/c#/GeneralUpdate.Client/Program.cs b/src/c#/GeneralUpdate.Client/Program.cs index f46a15ed..3e37065a 100644 --- a/src/c#/GeneralUpdate.Client/Program.cs +++ b/src/c#/GeneralUpdate.Client/Program.cs @@ -7,7 +7,8 @@ static void Main(string[] args) Task.Run(async() => { MySample sample = new MySample(); - await sample.TestDifferentialClean(); + //await sample.TestDifferentialClean(); + //await sample.TestDifferentialDirty(); }); Console.Read(); } diff --git a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs index 5f1a5b32..bf15a961 100644 --- a/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs +++ b/src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs @@ -48,23 +48,12 @@ public async Task> Except(string leftPath, string rightPat { var leftFileNodes = Read(leftPath); var rightFileNodes = Read(rightPath); - Dictionary dictB = rightFileNodes.ToDictionary(x => x.Name, x => x); - List filesOnlyInA = leftFileNodes.Where(f => !dictB.ContainsKey(f.Name)).ToList(); - return filesOnlyInA; + var rightNodeDic = rightFileNodes.ToDictionary(x => x.Name, x => x); + var filesOnlyInLeft = leftFileNodes.Where(f => !rightNodeDic.ContainsKey(f.Name)).ToList(); + return filesOnlyInLeft; }); } - private void Get(string leftPath, string rightPath) - { - var leftFileNodes = Directory.GetFiles(leftPath, "*", SearchOption.AllDirectories) - .Select(f => f.Substring(leftPath.Length)).ToList(); - - var rightFileNodes = Directory.GetFiles(rightPath, "*", SearchOption.AllDirectories) - .Select(f => f.Substring(rightPath.Length)).ToList(); - - leftFileNodes.Except(rightFileNodes).Select(x => leftPath + x).ToList(); - } - #endregion Public Methods #region Private Methods diff --git a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs index 0ca8dd2d..44ec20b8 100644 --- a/src/c#/GeneralUpdate.Differential/DifferentialCore.cs +++ b/src/c#/GeneralUpdate.Differential/DifferentialCore.cs @@ -34,8 +34,6 @@ public sealed class DifferentialCore /// private const string DELETE_FILES_NAME = "generalupdate_delete_files.json"; - private Action _compressProgressCallback; - #endregion Private Members #region Public Properties