Skip to content

Commit 1f6f88e

Browse files
committed
29.09.2025
1 parent 7860519 commit 1f6f88e

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

AppInit.cs

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,55 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7+
using System.Threading;
8+
using System.Threading.Tasks;
79

810
namespace JacRed
911
{
1012
public class AppInit
1113
{
1214
#region AppInit
13-
static (AppInit, DateTime) cacheconf = default;
14-
15-
public static AppInit conf
15+
static AppInit()
1616
{
17-
get
17+
void updateConf()
1818
{
19-
if (cacheconf.Item1 == null)
19+
try
2020
{
21-
if (!File.Exists("init.conf"))
22-
return new AppInit();
21+
if (cacheconf.Item1 == null)
22+
{
23+
if (!File.Exists("init.conf"))
24+
{
25+
cacheconf.Item1 = new AppInit();
26+
return;
27+
}
28+
}
29+
30+
var lastWriteTime = File.GetLastWriteTime("init.conf");
31+
32+
if (cacheconf.Item2 != lastWriteTime)
33+
{
34+
cacheconf.Item1 = JsonConvert.DeserializeObject<AppInit>(File.ReadAllText("init.conf"));
35+
cacheconf.Item2 = lastWriteTime;
36+
}
2337
}
38+
catch { }
39+
}
2440

25-
var lastWriteTime = File.GetLastWriteTime("init.conf");
41+
updateConf();
2642

27-
if (cacheconf.Item2 != lastWriteTime)
43+
ThreadPool.QueueUserWorkItem(async _ =>
44+
{
45+
while (true)
2846
{
29-
cacheconf.Item1 = JsonConvert.DeserializeObject<AppInit>(File.ReadAllText("init.conf"));
30-
cacheconf.Item2 = lastWriteTime;
47+
await Task.Delay(TimeSpan.FromSeconds(10));
48+
updateConf();
3149
}
32-
33-
return cacheconf.Item1;
34-
}
50+
});
3551
}
52+
53+
static (AppInit, DateTime) cacheconf = default;
54+
55+
public static AppInit conf => cacheconf.Item1;
3656
#endregion
3757

3858

@@ -72,7 +92,7 @@ public static AppInit conf
7292

7393
public string[] synctrackers = null;
7494

75-
public string[] disable_trackers = new string[] { "hdrezka", "anifilm" };
95+
public string[] disable_trackers = new string[] { "hdrezka", "anifilm", "anilibria" };
7696

7797
public bool syncsport = true;
7898

Controllers/SyncController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public ActionResult FdbTorrents(long time, long start = -1, bool spidr = false)
7474

7575
foreach (var t in FileDB.OpenRead(item.Key, cache: false))
7676
{
77+
if (AppInit.conf.disable_trackers != null && AppInit.conf.disable_trackers.Contains(t.Value.trackerName))
78+
continue;
79+
7780
if (spidr || (start != -1 && start > t.Value.updateTime.ToFileTimeUtc()))
7881
{
7982
torrent.TryAdd(t.Key, new TorrentDetails()
@@ -146,6 +149,9 @@ public JsonResult Torrents(long time)
146149
{
147150
foreach (var torrent in FileDB.OpenRead(item.Key, cache: false))
148151
{
152+
if (AppInit.conf.disable_trackers != null && AppInit.conf.disable_trackers.Contains(torrent.Value.trackerName))
153+
continue;
154+
149155
var _t = (TorrentDetails)torrent.Value.Clone();
150156
_t.updateTime = item.Value.updateTime;
151157

0 commit comments

Comments
 (0)