Skip to content

Commit 4167942

Browse files
committed
fix(emby): actually fix the dupes
1 parent a1d3755 commit 4167942

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/Ombi.Schedule/Jobs/Emby/EmbyEpisodeSync.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ private async Task CacheEpisodes(EmbyServers server, bool recentlyAdded, string
223223
{
224224
await _repo.AddRange(epToAdd);
225225
_logger.LogInformation($"Committed {epToAdd.Count} episodes to database. Progress: {processed}/{total}");
226+
227+
// Update the episode lookup with newly added episodes to prevent duplicates in subsequent batches
228+
foreach (var episode in epToAdd)
229+
{
230+
episodeLookup.Add(episode.EmbyId);
231+
}
226232
}
227233
epToAdd.Clear();
228234
episodesInCurrentBatch.Clear();
@@ -240,9 +246,14 @@ private async Task CacheEpisodes(EmbyServers server, bool recentlyAdded, string
240246
{
241247
await _repo.AddRange(epToAdd);
242248
_logger.LogInformation($"Final commit: {epToAdd.Count} episodes");
249+
250+
// Update the episode lookup with newly added episodes
251+
foreach (var episode in epToAdd)
252+
{
253+
episodeLookup.Add(episode.EmbyId);
254+
}
243255
}
244256
}
245-
246257
private bool _disposed;
247258
protected virtual void Dispose(bool disposing)
248259
{
@@ -262,4 +273,4 @@ public void Dispose()
262273
GC.SuppressFinalize(this);
263274
}
264275
}
265-
}
276+
}

0 commit comments

Comments
 (0)