Skip to content

Commit

Permalink
build:测试版本 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaboZhang authored Jan 17, 2025
2 parents eb75904 + f1254b5 commit 3f01d29
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
- 优化:优化验证逻辑
- 恢复:恢复加密功能(支持7zip 压缩加密跟AES-256 with PBKDF2-derived key 加密)7zip加密任意压缩工具都可进行解密;AES-256 with PBKDF2-derived key可使用openssl 等常见加密解密工具解密(支持任何标准 AES-CBC 解密工具),EasyTidy 解密功能预计下个版本中增加
- 修复:删除逻辑BUG
- 修复:处理文件夹时关联高级规则时会出现删除失败的情况

**网盘新增不包含winui跟.NET的版本,更新程序暂不支持更新不包含winui3AppSDK的版本**
**网盘中**EasyTidy_1.1.2.0105_win-x64_Lite 版本需要自行安装WindowsAppSDK 跟 .NET8 运行时

**Full Changelog**: <https://github.com/SaboZhang/EasyTidy/compare/1.1.3.0104...1.1.4.0117-alpha.4>
**Full Changelog**: <https://github.com/SaboZhang/EasyTidy/compare/1.1.3.0104...1.1.4.0117-alpha.5>

网盘下载:[123网盘](https://www.123684.com/s/hbzgTd-fmmt)|[蓝奏云(2025)](https://wwoo.lanzouu.com/b02u2ne0eh)
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@

[**English**](./README_EN.md) | **简体中文**

EasyTidy 是一款功能强大的文件管理软件。它能够自动处理和组织文件与文件夹,让你的文件系统变得井井有条。 特色功能包括: 强大的文件过滤:可以依据文件名称、所在目录、大小、日期、属性、内容或者常规表达式来筛选文件,精准定位你所需的文件。 灵活的执行模式:支持手动操作和自动执行。在自动执行方面,你可以设置延时启动,也可以按照固定的时间间隔执行,还能通过 CRON 表达式自定义执行周期,满足不同场景下的文件管理需求。开源且免费
EasyTidy 是一款功能强大的文件管理软件,致力于自动化处理和组织文件与文件夹,使您的文件系统保持整洁有序。其主要特色功能包括:

快速开始:[使用文档](https://easytidy.luckyits.com)
- **强大的文件过滤功能**:支持根据文件名称、所在目录、大小、日期、属性、内容以及常规表达式精准筛选文件,帮助您高效定位所需文件。
- **灵活的执行模式**:不仅支持手动操作,还能自动执行。您可以设置延时启动、定时执行或通过 CRON 表达式自定义执行周期,满足不同场景下的文件管理需求。
- **开源且免费**:完全免费且开源,欢迎大家参与并贡献代码。

如果你觉得 DropIT 的任务监控无法满足需求,或者 File Juggler 3 的价格不太合适,可以尝试一下 EasyTidy。目前 EasyTidy 正在积极开发中,欢迎提出您的需求,我会考虑并接受一些合理的功能请求。
### 快速开始

使用技术:C# .net8 winui3 实现
[使用文档](https://easytidy.luckyits.com)

如果您觉得 DropIT 的任务监控无法满足需求,或 File Juggler 3 的定价不符合预算,不妨尝试 EasyTidy。目前,EasyTidy 正在积极开发中,欢迎提出您的需求,我会考虑并接受合理的功能请求。

### 使用技术

- C#
- .NET 8
- WinUI 3

## 关于 License

Expand All @@ -44,6 +54,7 @@ EasyTidy 是一款功能强大的文件管理软件。它能够自动处理和
- [x] 定期执行
- [x] 按照计划执行
- [x] 关闭时执行
- [ ] 本地化支持;目前支持**简体中文****繁體中文****English****日本語****Français**;欢迎大家参与并贡献其他语种的翻译。[本地化语言文件](https://github.com/SaboZhang/EasyTidy/tree/main/src/EasyTidy/MultilingualResources)

## 功能规划

Expand All @@ -67,4 +78,4 @@ EasyTidy 是一款功能强大的文件管理软件。它能够自动处理和

## 社区参与

欢迎所有人的反馈和贡献!如果你有任何建议或想要帮忙,请访问我们的 [问题跟踪器](https://github.com/SaboZhang/EasyTidy/issues) 或通过邮件与我联系<service@luckyits.com> 或者 <tao993859833@Live.cn>
欢迎所有人的反馈和贡献!如果你有任何建议或想要帮忙,请访问我们的 [问题跟踪器](https://github.com/SaboZhang/EasyTidy/issues) 也可通过邮件与我联系<service@luckyits.com> 或者 <tao993859833@Live.cn>
19 changes: 15 additions & 4 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@

**English** | [**简体中文**](./README.md)

EasyTidy is a powerful file management software. It can automatically process and organize files and folders, leaving your file system in an orderly manner. Features include: Powerful file filtering: You can filter files by file name, directory, size, date, attributes, content or regular expressions to accurately locate the files you need. Flexible execution mode: Supports manual operation and automatic execution. In terms of automatic execution, you can set a delay start, or you can execute it at fixed intervals, and you can also customize the execution cycle through the CRON expression to meet the file management needs in different scenarios.Open source and free
EasyTidy is a powerful file management software that automates the organization and handling of files and folders, keeping your file system neat and organized. Key features include:

Quick start:[Documentation](https://easytidy.luckyits.com)
- **Powerful File Filtering**: Filter files accurately based on their name, location, size, date, attributes, content, or regular expressions, making it easy to locate the files you need.
- **Flexible Execution Modes**: Supports both manual and automatic execution. You can set delayed starts, periodic execution, or define custom schedules using CRON expressions, catering to different file management needs.
- **Open Source and Free**: Fully open-source and free to use. We welcome contributions and feedback from the community.

If you find that DropIT's task monitoring doesn't meet your needs, or the price of File Juggler 3 is not quite suitable, you can give EasyTidy a try. EasyTidy is currently under active development, and we welcome your suggestions. Reasonable feature requests will be considered and accepted.
### Getting Started

Technology used: C# .net8 winui3 implementation
[Documentation](https://easytidy.luckyits.com)

If you find DropIT's task monitoring insufficient or if File Juggler 3's pricing doesn't fit your needs, consider trying EasyTidy. It is actively under development, and we welcome feature requests which will be considered and accepted where reasonable.

### Technologies Used

- C#
- .NET 8
- WinUI 3

## License

Expand All @@ -44,6 +54,7 @@ This project is licensed under the MIT License. However, the **Snap2HTML** snaps
- [x] Execute Periodically
- [x] Execute as Scheduled
- [x] Execute on Shutdown
- [ ] Localization Support: Currently supports **简体中文**, **繁體中文**, **English**, **日本語**, **Français**. We welcome everyone to participate and contribute translations in other languages.[Localization language files](https://github.com/SaboZhang/EasyTidy/tree/main/src/EasyTidy/MultilingualResources)

## Feature Roadmap

Expand Down
34 changes: 33 additions & 1 deletion src/EasyTidy.Util/Strategy/AttributeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ public AttributeFilter(FileAttributes attribute, YesOrNo value)

public Func<string, bool> GenerateFilter(FilterTable filter)
{
return filePath => new FileInfo(filePath).Attributes.HasFlag(_attribute) == (_value == YesOrNo.Yes);
return path =>
{
// 检查路径是否有效
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("Path cannot be null or empty.", nameof(path));
}

// 判断是文件还是文件夹,并获取其属性
FileAttributes attributes = GetAttributes(path);

// 检查属性是否匹配
bool hasFlag = attributes.HasFlag(_attribute);
return hasFlag == (_value == YesOrNo.Yes);
};
}

// 获取文件或文件夹的属性
private FileAttributes GetAttributes(string path)
{
if (File.Exists(path))
{
return new FileInfo(path).Attributes;
}
else if (Directory.Exists(path))
{
return new DirectoryInfo(path).Attributes;
}
else
{
throw new FileNotFoundException($"The path '{path}' does not exist as a file or directory.");
}
}

}
56 changes: 45 additions & 11 deletions src/EasyTidy.Util/Strategy/DateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,60 @@ public DateFilter(string dateValue, DateUnit dateUnit, ComparisonResult dateOper

public Func<string, bool> GenerateFilter(FilterTable filter)
{
return filePath =>
return path =>
{
DateTime fileDate = _dateType switch
// 检查路径是否有效
if (string.IsNullOrWhiteSpace(path))
{
DateType.Create => File.GetCreationTime(filePath),
DateType.Edit => File.GetLastWriteTime(filePath),
DateType.Visit => File.GetLastAccessTime(filePath),
_ => DateTime.Now
};
throw new ArgumentException("Path cannot be null or empty.", nameof(path));
}

DateTime entityDate = GetEntityDate(path, _dateType);

// 转换日期范围或单个日期
var result = FilterUtil.ConvertToDateTime(_dateValue, _dateUnit);
if (result is Tuple<DateTime, DateTime> dateTuple)
if (result is Tuple<DateTime, DateTime> dateRange)
{
return FilterUtil.CompareDates(fileDate, _dateOperator, dateTuple.Item1, dateTuple.Item2);
return FilterUtil.CompareDates(entityDate, _dateOperator, dateRange.Item1, dateRange.Item2);
}
else if (result is DateTime singleDate)
{
return FilterUtil.CompareDates(fileDate,_dateOperator, singleDate);
return FilterUtil.CompareDates(entityDate, _dateOperator, singleDate);
}
return FilterUtil.CompareDates(fileDate, _dateOperator, DateTime.Now);

// 默认返回 false(防止意外情况)
return false;
};
}

// 根据路径类型获取日期
private DateTime GetEntityDate(string path, DateType dateType)
{
if (File.Exists(path))
{
return dateType switch
{
DateType.Create => File.GetCreationTime(path),
DateType.Edit => File.GetLastWriteTime(path),
DateType.Visit => File.GetLastAccessTime(path),
_ => DateTime.Now
};
}
else if (Directory.Exists(path))
{
var directoryInfo = new DirectoryInfo(path);
return dateType switch
{
DateType.Create => directoryInfo.CreationTime,
DateType.Edit => directoryInfo.LastWriteTime,
DateType.Visit => directoryInfo.LastAccessTime,
_ => DateTime.Now
};
}
else
{
throw new FileNotFoundException($"The path '{path}' does not exist as a file or directory.");
}
}

}
69 changes: 64 additions & 5 deletions src/EasyTidy.Util/Strategy/SizeFilter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EasyTidy.Model;
using EasyTidy.Log;
using EasyTidy.Model;
using EasyTidy.Util.UtilInterface;
using System;
using System.Collections.Generic;
Expand All @@ -24,11 +25,69 @@ public SizeFilter(string sizeValue, SizeUnit sizeUnit, ComparisonResult sizeOper

public Func<string, bool> GenerateFilter(FilterTable filter)
{
return filePath =>
// 检查路径并返回是否符合过滤条件
return path =>
{
long fileSize = new FileInfo(filePath).Length;
var (firstSize, secondSize) = FilterUtil.ConvertSizeToBytes(_sizeValue, _sizeUnit);
return FilterUtil.CompareValues(fileSize, firstSize, secondSize, _sizeOperator);
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentException("Path cannot be null or empty.", nameof(path));
}

if (File.Exists(path))
{
return IsFileMatch(path, filter);
}

if (Directory.Exists(path))
{
return IsDirectoryMatch(path, filter);
}

// 非文件或文件夹的路径直接返回 false
return false;
};
}

// 检查文件是否符合过滤条件
private bool IsFileMatch(string filePath, FilterTable filter)
{
var fileInfo = new FileInfo(filePath);
long fileSize = fileInfo.Length;

var (minSize, maxSize) = FilterUtil.ConvertSizeToBytes(filter.SizeValue, filter.SizeUnit);
return FilterUtil.CompareValues(fileSize, minSize, maxSize, filter.SizeOperator);
}

// 检查文件夹是否符合过滤条件
private bool IsDirectoryMatch(string directoryPath, FilterTable filter)
{
var directoryInfo = new DirectoryInfo(directoryPath);
long folderSize = CalculateDirectorySize(directoryInfo);
LogService.Logger.Debug($"文件夹大小{folderSize}");

var (minSize, maxSize) = FilterUtil.ConvertSizeToBytes(filter.SizeValue, filter.SizeUnit);
return FilterUtil.CompareValues(folderSize, minSize, maxSize, filter.SizeOperator);
}

// 计算文件夹的总大小(包括子文件夹中的所有文件)
private long CalculateDirectorySize(DirectoryInfo directoryInfo)
{
try
{
return directoryInfo.EnumerateFiles("*", SearchOption.AllDirectories)
.Sum(file => file.Length);
}
catch (UnauthorizedAccessException)
{
// 忽略无权限访问的文件或文件夹
return 0;
}
catch (Exception ex)
{
// 记录异常日志(假设有日志工具)
LogService.Logger.Error($"Failed to calculate directory size for {directoryInfo.FullName}: {ex.Message}");
return 0;
}
}

}

0 comments on commit 3f01d29

Please sign in to comment.