Skip to content

Commit

Permalink
1、新增 MD5 的匹配方式
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Feb 22, 2022
1 parent a05e362 commit 785917f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/FindDuplicateFiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Win32Resource />
<Authors>九零</Authors>
<Product>重复文件查找</Product>
<Version>1.6.2</Version>
<Version>1.7.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -202,8 +202,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JiuLing.AutoUpgrade" Version="1.2.1" />
<PackageReference Include="JiuLing.CommonLibs" Version="1.2.1" />
<PackageReference Include="JiuLing.AutoUpgrade" Version="1.2.2" />
<PackageReference Include="JiuLing.CommonLibs" Version="1.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<!-- 左侧功能面板 -->
<Grid Grid.Column="0" >
<Grid.RowDefinitions>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="200"></RowDefinition>
<RowDefinition Height="240"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
Expand All @@ -106,7 +106,8 @@
<TextBlock FontWeight="Bold" Foreground="{DynamicResource FontForeground}" VerticalAlignment="Center">匹配方式</TextBlock>
<CheckBox Name="ChkFileName" Foreground="{DynamicResource FontForeground}" Margin="0,2,0,5">文件名</CheckBox>
<CheckBox Name="ChkFileSize" Foreground="{DynamicResource FontForeground}" Margin="0,0,0,5">文件大小</CheckBox>
<CheckBox Name="ChkFileLastWriteTimeUtc" Foreground="{DynamicResource FontForeground}">文件修改时间</CheckBox>
<CheckBox Name="ChkFileLastWriteTimeUtc" Foreground="{DynamicResource FontForeground}" Margin="0,0,0,5">文件修改时间</CheckBox>
<CheckBox Name="ChkMD5" Foreground="{DynamicResource FontForeground}">MD5(速度慢,准确性高)</CheckBox>
</StackPanel>
</Border>
</Grid>
Expand Down
11 changes: 8 additions & 3 deletions src/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ private void LoadingAppConfig()
private void InitializeSearchCondition()
{
//匹配方式
ChkFileName.IsChecked = true;
ChkFileSize.IsChecked = true;
ChkFileLastWriteTimeUtc.IsChecked = true;
ChkFileName.IsChecked = false;
ChkFileSize.IsChecked = false;
ChkFileLastWriteTimeUtc.IsChecked = false;
ChkMD5.IsChecked = true;

//选项
ChkIgnoreEmptyFile.IsChecked = true;
Expand Down Expand Up @@ -227,6 +228,10 @@ private void BeginSearch()
{
searchMatch |= SearchMatchEnum.LastWriteTime;
}
if (ChkMD5.IsChecked == true)
{
searchMatch |= SearchMatchEnum.MD5;
}
if (searchMatch == 0)
{
MessageBox.Show("请选择匹配方式", "重复文件查找", MessageBoxButton.OK, MessageBoxImage.Stop);
Expand Down
3 changes: 2 additions & 1 deletion src/Model/SearchConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum SearchMatchEnum
{
Name = 1,
Size = 2,
LastWriteTime = 4
LastWriteTime = 4,
MD5 = 8,
}
/// <summary>
/// 查找选项
Expand Down
8 changes: 7 additions & 1 deletion src/SearchFile/CheckDuplicateQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ private async void SearchDuplicate(SimpleFileInfo fileInfo)
fileKey = $"{fileKey}${fileInfo.LastWriteTime:yyyy-MM-dd HH:mm:ss}";
}

var newFile = new List<SimpleFileInfo> {fileInfo};
if ((_searchMatch & SearchMatchEnum.MD5) == SearchMatchEnum.MD5)
{
string md5 = JiuLing.CommonLibs.Security.MD5Utils.GetFileValueToLower(fileInfo.Path);
fileKey = $"{fileKey}${md5}";
}

var newFile = new List<SimpleFileInfo> { fileInfo };
var resultFile = _duplicateFiles.AddOrUpdate(fileKey, newFile, (x, oldValue) =>
{
oldValue.Add(fileInfo);
Expand Down

0 comments on commit 785917f

Please sign in to comment.