Skip to content

Commit

Permalink
fix: Identify bugs that require files to be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Dec 28, 2023
1 parent 3ac3d93 commit 90da933
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
8 changes: 8 additions & 0 deletions src/c#/GeneralUpdate.Client/MySample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using GeneralUpdate.Core.Domain.Enum;
using GeneralUpdate.Core.Events.CommonArgs;
using GeneralUpdate.Differential;
using System.IO;

namespace GeneralUpdate.Client
{
Expand Down Expand Up @@ -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
}
}
3 changes: 2 additions & 1 deletion src/c#/GeneralUpdate.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
17 changes: 3 additions & 14 deletions src/c#/GeneralUpdate.Differential/ContentProvider/FileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,12 @@ public async Task<IEnumerable<FileNode>> Except(string leftPath, string rightPat
{
var leftFileNodes = Read(leftPath);
var rightFileNodes = Read(rightPath);
Dictionary<string, FileNode> dictB = rightFileNodes.ToDictionary(x => x.Name, x => x);
List<FileNode> 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
Expand Down
2 changes: 0 additions & 2 deletions src/c#/GeneralUpdate.Differential/DifferentialCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public sealed class DifferentialCore
/// </summary>
private const string DELETE_FILES_NAME = "generalupdate_delete_files.json";

private Action<object, BaseCompressProgressEventArgs> _compressProgressCallback;

#endregion Private Members

#region Public Properties
Expand Down

0 comments on commit 90da933

Please sign in to comment.