|
4 | 4 | using System; |
5 | 5 | using System.Collections.Generic; |
6 | 6 | using System.IO; |
| 7 | +using System.Threading; |
| 8 | +using System.Threading.Tasks; |
7 | 9 |
|
8 | 10 | namespace JacRed |
9 | 11 | { |
10 | 12 | public class AppInit |
11 | 13 | { |
12 | 14 | #region AppInit |
13 | | - static (AppInit, DateTime) cacheconf = default; |
14 | | - |
15 | | - public static AppInit conf |
| 15 | + static AppInit() |
16 | 16 | { |
17 | | - get |
| 17 | + void updateConf() |
18 | 18 | { |
19 | | - if (cacheconf.Item1 == null) |
| 19 | + try |
20 | 20 | { |
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 | + } |
23 | 37 | } |
| 38 | + catch { } |
| 39 | + } |
24 | 40 |
|
25 | | - var lastWriteTime = File.GetLastWriteTime("init.conf"); |
| 41 | + updateConf(); |
26 | 42 |
|
27 | | - if (cacheconf.Item2 != lastWriteTime) |
| 43 | + ThreadPool.QueueUserWorkItem(async _ => |
| 44 | + { |
| 45 | + while (true) |
28 | 46 | { |
29 | | - cacheconf.Item1 = JsonConvert.DeserializeObject<AppInit>(File.ReadAllText("init.conf")); |
30 | | - cacheconf.Item2 = lastWriteTime; |
| 47 | + await Task.Delay(TimeSpan.FromSeconds(10)); |
| 48 | + updateConf(); |
31 | 49 | } |
32 | | - |
33 | | - return cacheconf.Item1; |
34 | | - } |
| 50 | + }); |
35 | 51 | } |
| 52 | + |
| 53 | + static (AppInit, DateTime) cacheconf = default; |
| 54 | + |
| 55 | + public static AppInit conf => cacheconf.Item1; |
36 | 56 | #endregion |
37 | 57 |
|
38 | 58 |
|
@@ -72,7 +92,7 @@ public static AppInit conf |
72 | 92 |
|
73 | 93 | public string[] synctrackers = null; |
74 | 94 |
|
75 | | - public string[] disable_trackers = new string[] { "hdrezka", "anifilm" }; |
| 95 | + public string[] disable_trackers = new string[] { "hdrezka", "anifilm", "anilibria" }; |
76 | 96 |
|
77 | 97 | public bool syncsport = true; |
78 | 98 |
|
|
0 commit comments