Skip to content

Commit c96086b

Browse files
committed
dev
1 parent d10005b commit c96086b

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

Controllers/SyncController.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public JsonResult Torrents(long time)
126126
return Json(new List<string>());
127127

128128
int take = 2_000;
129-
var torrents = new Dictionary<string, TorrentDetails>();
129+
var torrents = new List<Models.Sync.v1.Torrent>(take+1);
130130

131131
if (!memoryCache.TryGetValue("sync:masterDb", out Dictionary<string, TorrentInfo> masterDb))
132132
{
@@ -139,6 +139,7 @@ public JsonResult Torrents(long time)
139139
foreach (var torrent in FileDB.OpenRead(item.Key, cache: false))
140140
{
141141
var _t = (TorrentDetails)torrent.Value.Clone();
142+
_t.updateTime = item.Value.updateTime;
142143

143144
var streams = TracksDB.Get(_t.magnet, _t.types);
144145
if (streams != null)
@@ -147,15 +148,7 @@ public JsonResult Torrents(long time)
147148
_t.languages = TracksDB.Languages(_t, streams);
148149
}
149150

150-
if (torrents.TryGetValue(torrent.Key, out TorrentDetails val))
151-
{
152-
if (torrent.Value.updateTime > val.updateTime)
153-
torrents[torrent.Key] = _t;
154-
}
155-
else
156-
{
157-
torrents.TryAdd(torrent.Key, _t);
158-
}
151+
torrents.Add(new Models.Sync.v1.Torrent() { key = torrent.Key, value = _t });
159152
}
160153

161154
if (torrents.Count > take)
@@ -165,7 +158,7 @@ public JsonResult Torrents(long time)
165158
}
166159
}
167160

168-
return Json(new { take, torrents = torrents.OrderBy(i => i.Value.updateTime) });
161+
return Json(new { take, torrents });
169162
}
170163
}
171164
}

Engine/SyncCron.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JacRed.Engine.CORE;
22
using JacRed.Models.Details;
3-
using JacRed.Models.Sync;
43
using Newtonsoft.Json.Linq;
54
using System;
65
using System.Collections.Generic;
@@ -101,7 +100,7 @@ async public static Task Torrents()
101100
else
102101
{
103102
#region Sync.v1
104-
next: var root = await HttpClient.Get<RootObject>($"{AppInit.conf.syncapi}/sync/torrents?time={lastsync}", timeoutSeconds: 300, MaxResponseContentBufferSize: 100_000_000);
103+
next: var root = await HttpClient.Get<Models.Sync.v1.RootObject>($"{AppInit.conf.syncapi}/sync/torrents?time={lastsync}", timeoutSeconds: 300, MaxResponseContentBufferSize: 100_000_000);
105104
if (root?.torrents != null && root.torrents.Count > 0)
106105
{
107106
FileDB.AddOrUpdate(root.torrents.Select(i => i.value).ToList());

Models/Sync/RootObject.cs renamed to Models/Sync/v1/RootObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Generic;
22

3-
namespace JacRed.Models.Sync
3+
namespace JacRed.Models.Sync.v1
44
{
55
public class RootObject
66
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using JacRed.Models.Details;
22

3-
namespace JacRed.Models.Sync
3+
namespace JacRed.Models.Sync.v1
44
{
55
public class Torrent
66
{
77
public string key { get; set; }
88

9-
public TorrentBaseDetails value { get; set; }
9+
public TorrentDetails value { get; set; }
1010
}
1111
}

0 commit comments

Comments
 (0)