diff --git a/AppInit.cs b/AppInit.cs index d8b2e5d..26a5c34 100644 --- a/AppInit.cs +++ b/AppInit.cs @@ -35,6 +35,7 @@ public static AppInit conf } #endregion + public string torrentsStatFile = "Data/temp/stats.json"; public string listenip = "any"; diff --git a/Controllers/StatsController.cs b/Controllers/StatsController.cs index 47e8cd4..cf206ff 100644 --- a/Controllers/StatsController.cs +++ b/Controllers/StatsController.cs @@ -16,7 +16,10 @@ public ActionResult Torrents(string trackerName) if (string.IsNullOrWhiteSpace(trackerName)) { - return Content(System.IO.File.ReadAllText("Data/temp/stats.json")); + if (System.IO.File.Exists(AppInit.conf.torrentsStatFile)) + return Content(System.IO.File.ReadAllText(AppInit.conf.torrentsStatFile)); + else + return Content(string.Empty); } else { diff --git a/Engine/StatsCron.cs b/Engine/StatsCron.cs index f5f72be..39e87e1 100644 --- a/Engine/StatsCron.cs +++ b/Engine/StatsCron.cs @@ -71,7 +71,7 @@ async public static Task Run() } } - File.WriteAllText("Data/temp/stats.json", JsonConvert.SerializeObject(stats.OrderByDescending(i => i.Value.alltorrents).Select(i => new + File.WriteAllText(AppInit.conf.torrentsStatFile, JsonConvert.SerializeObject(stats.OrderByDescending(i => i.Value.alltorrents).Select(i => new { trackerName = i.Key, lastnewtor = i.Value.lastnewtor.ToString("dd.MM.yyyy"),