chore: check if uri exists before adding to table

This commit is contained in:
Hachi-R 2024-11-04 14:02:48 -03:00
parent 92ec056ba8
commit 1ad501c64e

View file

@ -63,10 +63,21 @@ export class DownloadManager {
userPreferences?.seedAfterDownloadCompletes && userPreferences?.seedAfterDownloadCompletes &&
this.currentDownloader === Downloader.Torrent this.currentDownloader === Downloader.Torrent
) { ) {
const existingSeed = await seedListRepository.findOne({
where: { downloadUri: game.uri! }
});
if (existingSeed) {
await seedListRepository.update(
{ downloadUri: game.uri! },
{ shouldSeed: true }
);
} else {
await seedListRepository.save({ await seedListRepository.save({
downloadUri: game.uri!, downloadUri: game.uri!,
shouldSeed: true, shouldSeed: true,
}); });
}
this.startSeedDownload(game); this.startSeedDownload(game);
} }