diff --git a/README.md b/README.md
index fffbf3c..ddf2e58 100644
--- a/README.md
+++ b/README.md
@@ -8,5 +8,6 @@
- [x] 文件大小限制
- [x] 基于IP查询提交的任务状态
- [x] 基于IP和路由的请求次数限制
+- [ ] 任务队列
- [ ] 已经存在对应文件时候直接跳过代理下载 直接下载已经缓存的内容
- [ ] 捐赠
\ No newline at end of file
diff --git a/src/Config/AppConfig.cs b/src/Config/AppConfig.cs
index f3de6a4..2536e71 100644
--- a/src/Config/AppConfig.cs
+++ b/src/Config/AppConfig.cs
@@ -1,4 +1,5 @@
-using Serilog;
+using iFileProxy.Helpers;
+using Serilog;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -40,6 +41,33 @@ namespace iFileProxy.Config
_logger.Fatal($"Config File: {configPath} not exists!");
return null;
}
+ public static void CheckAppConfig()
+ {
+ AppConfig? c = GetCurrConfig();
+ if (c != null)
+ {
+ if (!Directory.Exists(c.DownloadOptions.SavePath))
+ {
+ _logger.Warning($"下载路径不存在, 尝试创建文件夹...");
+ Directory.CreateDirectory(c.DownloadOptions.SavePath);
+ _logger.Warning($"succ.");
+ }
+
+ if (!File.Exists(c.DownloadOptions.Aria2cPath))
+ {
+ _logger.Fatal("Aria2c 路径错误!");
+ Environment.Exit(1);
+ }
+
+ DatabaseHelper databaseHelper = new(c);
+ databaseHelper.TestDbConfig();
+ }
+ else
+ {
+ _logger.Error("配置为空!");
+ Environment.Exit(1);
+ }
+ }
}
public class DownloadOptions
@@ -49,6 +77,7 @@ namespace iFileProxy.Config
public uint MaxAllowedFileSize { get; set; }
public uint MaxParallelTasks { get; set; } = 4;
public string Aria2cPath { get; set; } = "./bin/aria2c";
+ public int CacheLifetime { get; set; } = 3600;
}
public class SecurityOptions
{
diff --git a/src/Helpers/DatabaseHelper.cs b/src/Helpers/DatabaseHelper.cs
index 55d3c19..1bfddaa 100644
--- a/src/Helpers/DatabaseHelper.cs
+++ b/src/Helpers/DatabaseHelper.cs
@@ -79,6 +79,31 @@ namespace iFileProxy.Helpers
}
return conn;
}
+
+ public bool TestDbConfig()
+ {
+ foreach (var db in _dbDictionary)
+ {
+ _logger.Information($"[程序启动前配置验证] 正在测试数据库配置: {db.Key} ...");
+ MySqlConnection dbConn = new();
+ try
+ {
+ dbConn = GetAndOpenDBConn(db.Key);
+ _logger.Information($"succ.");
+ }
+ catch (Exception)
+ {
+ _logger.Fatal($"=========== 数据库: {db.Key} 测试失败! ===========");
+ return false;
+ }
+ finally
+ {
+ dbConn.Close();
+ }
+ }
+ return true;
+ }
+
///
/// 获取一个json格式的数据表
///
diff --git a/src/Models/Task.cs b/src/Models/Task.cs
index d9a446b..1ccbd1c 100644
--- a/src/Models/Task.cs
+++ b/src/Models/Task.cs
@@ -1,10 +1,11 @@
namespace iFileProxy.Models
{
- public enum TaskState {
+ public enum TaskState {
NoInit = 0, // 还未初始化
Running = 1, // 正在进行
Error = 2, // 任务执行时候发生错误 已经结束
End = 3, // 任务正常结束
+ Cached = 4, // 要下载的内容已经缓存
}
public enum TaskAddState {
Success = 0,
diff --git a/src/Program.cs b/src/Program.cs
index e38a0e5..18b09c4 100644
--- a/src/Program.cs
+++ b/src/Program.cs
@@ -12,6 +12,10 @@ namespace iFileProxy
SerilogConfig.CreateLogger();
Serilog.ILogger logger = Log.Logger.ForContext();
+ Console.Write(" ");
+
+ AppConfig.CheckAppConfig();
+
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
diff --git a/src/Properties/PublishProfiles/FolderProfile.pubxml b/src/Properties/PublishProfiles/FolderProfile.pubxml
index 1296e0c..8285a16 100644
--- a/src/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/src/Properties/PublishProfiles/FolderProfile.pubxml
@@ -15,7 +15,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<_TargetId>Folder
net8.0
- linux-x64
+ win-x64
e343bd8a-27ed-47e2-b50d-e3000730e65e
false
true
diff --git a/src/Services/LocalCacheManager.cs b/src/Services/LocalCacheManager.cs
new file mode 100644
index 0000000..97133d3
--- /dev/null
+++ b/src/Services/LocalCacheManager.cs
@@ -0,0 +1,9 @@
+namespace iFileProxy.Services
+{
+ ///
+ /// 本地缓存管理器
+ ///
+ public class LocalCacheManager
+ {
+ }
+}
diff --git a/src/iFileProxy.json b/src/iFileProxy.json
index 1cc9a30..0352c1a 100644
--- a/src/iFileProxy.json
+++ b/src/iFileProxy.json
@@ -18,7 +18,8 @@
"ThreadNum": 4, // 下载线程数
"MaxAllowedFileSize": 65536, // 允许代理的最大文件尺寸
"MaxParallelTasks": 4, // 同一时间最大并行任务数
- "Aria2cPath": "./lib/aria2c"
+ "Aria2cPath": "./lib/aria2c",
+ "CacheLifetime": 3600 // 缓存生命周期(秒) 超出此范围的缓存文件将被删除
},
"Security": {
"BlockedHost": [ // 禁止代理的主机
diff --git a/src/wwwroot/index.html b/src/wwwroot/index.html
index d8eace0..0eb9b29 100644
--- a/src/wwwroot/index.html
+++ b/src/wwwroot/index.html
@@ -7,51 +7,7 @@
Github文件下载加速
-
-
+
@@ -62,7 +18,7 @@
Github文件下载加速
@@ -95,19 +51,8 @@
+
+
+