Only send notification on successful downloads

This commit is contained in:
glax 2023-09-20 14:40:03 +02:00
parent 4e5a6fe97b
commit 3ceee63dfc
2 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,5 @@
using Tranga.MangaConnectors;
using System.Net;
using Tranga.MangaConnectors;
namespace Tranga.Jobs;
@ -31,9 +32,12 @@ public class DownloadChapter : Job
Task downloadTask = new(delegate
{
mangaConnector.CopyCoverFromCacheToDownloadLocation(chapter.parentManga);
mangaConnector.DownloadChapter(chapter, this.progressToken);
UpdateLibraries();
SendNotifications("Chapter downloaded", $"{chapter.parentManga.sortName} - {chapter.chapterNumber}");
HttpStatusCode success = mangaConnector.DownloadChapter(chapter, this.progressToken);
if (success == HttpStatusCode.OK)
{
UpdateLibraries();
SendNotifications("Chapter downloaded", $"{chapter.parentManga.sortName} - {chapter.chapterNumber}");
}
});
downloadTask.Start();
return Array.Empty<Job>();

View File

@ -200,7 +200,7 @@ public abstract class MangaConnector : GlobalBase
Directory.CreateDirectory(directoryPath);
if (File.Exists(saveArchiveFilePath)) //Don't download twice.
return HttpStatusCode.OK;
return HttpStatusCode.Created;
//Create a temporary folder to store images
string tempFolder = Directory.CreateTempSubdirectory().FullName;