Skip to content

Commit

Permalink
Merge pull request #40 from GeneralLibrary/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
JusterZhu authored Jan 18, 2024
2 parents fea370a + daab9da commit 1f07560
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<None Remove="Pipelines\Middleware\.gitkeep" />
<None Remove="Pipelines\Pipeline\.gitkeep" />
<None Remove="Strategys\PlatformLinux\.gitkeep" />
<None Remove="Strategys\PlatformMac\.gitkeep" />
<None Remove="Strategys\PlatformWindows\.gitkeep" />
<None Remove="Utils\.gitkeep" />
<None Remove="ZipFactory\Events\.gitkeep" />
Expand Down Expand Up @@ -150,7 +149,6 @@
<Compile Include="..\GeneralUpdate.Core\Strategys\AbstractStrategy.cs" Link="Strategys\AbstractStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\IStrategy.cs" Link="Strategys\IStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\PlatformLinux\LinuxStrategy.cs" Link="Strategys\PlatformLinux\LinuxStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\PlatformMac\MacStrategy.cs" Link="Strategys\PlatformMac\MacStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Strategys\PlatformWindows\WindowsStrategy.cs" Link="Strategys\PlatformWindows\WindowsStrategy.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\ConvertUtil.cs" Link="Utils\ConvertUtil.cs" />
<Compile Include="..\GeneralUpdate.Core\Utils\FileUtil.cs" Link="Utils\FileUtil.cs" />
Expand Down Expand Up @@ -244,10 +242,8 @@
<Folder Include="Pipelines\MiddlewareResolver\" />
<Folder Include="Pipelines\Pipeline\" />
<Folder Include="Strategys\PlatformWindows\" />
<Folder Include="Strategys\PlatformMac\" />
<Folder Include="Strategys\PlatformLinux\" />
<Folder Include="Strategys\PlatformLinux\" />
<Folder Include="Strategys\PlatformMac\" />
<Folder Include="Strategys\PlatformWindows\" />
<Folder Include="Utils\" />
<Folder Include="Pipelines\Attributes\" />
Expand Down
Empty file.
19 changes: 3 additions & 16 deletions src/c#/GeneralUpdate.Core/ContentProvider/FileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,8 @@ private bool IsMatchBlacklist(string subPath)
/// <param name="recursion">整个方法里的操作是否递归执行</param>
/// <param name="integrality">是否保持目录结构的完整性</param>
/// <returns></returns>
//public List<FileNode> Handle(string sourceDir,string targetDir, string resultDir, List<string> condition, FileOperations fileOption, SetOperations setOperations,bool recursion,bool integrality)
//{
// return new List<FileNode>();
//}

public List<FileNode> Handle(string sourceDir, string targetDir, string resultDir, List<string> condition, FileOperations fileOption, SetOperations setOperations, bool recursion, bool integrality)
{
// 首先获取源目录和目标目录中所有的文件信息
IEnumerable<FileNode> sourceFiles = Directory.EnumerateFiles(sourceDir, "*.*", recursion ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)
.Select(path => new FileInfo(path))
.Select(fileInfo => new FileNode
Expand All @@ -174,7 +168,6 @@ public List<FileNode> Handle(string sourceDir, string targetDir, string resultDi
IEnumerable<FileNode> filteredSourceFiles = sourceFiles.Where(file => condition.Any(c => file.Name.Contains(c) || file.Name.EndsWith(c)));
IEnumerable<FileNode> filteredTargetFiles = targetFiles.Where(file => condition.Any(c => file.Name.Contains(c) || file.Name.EndsWith(c)));

// 进行集合运算以得到最终的结果
IEnumerable<FileNode> resultFiles;
switch (setOperations)
{
Expand All @@ -191,24 +184,18 @@ public List<FileNode> Handle(string sourceDir, string targetDir, string resultDi
throw new ArgumentException("Invalid operation.", nameof(setOperations));
}

// 执行文件操作
foreach (FileNode file in resultFiles)
foreach (var file in resultFiles)
{
ExecuteFileOperation(file, fileOption, resultDir, integrality);
}

return resultFiles.ToList();
}

/// <summary>
/// 计算文件的哈希值.
/// </summary>
/// <param name="file">文件对象.</param>
/// <returns></returns>
private string CalculateFileHash(FileInfo file)
{
// 这里只是一个占位符,实际上你需要实现一个方法来计算文件哈希值.
return string.Empty;
var hashAlgorithm = new Sha256HashAlgorithm();
return hashAlgorithm.ComputeHash(file.FullName);
}

/// <summary>
Expand Down

0 comments on commit 1f07560

Please sign in to comment.