diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs index b05854e..f984c4c 100644 --- a/Tranga/Connector.cs +++ b/Tranga/Connector.cs @@ -20,6 +20,15 @@ public abstract class Connector protected void DownloadChapter(string[] imageUrls, string saveArchiveFilePath) { + string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar); + string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray()); + if (!Directory.Exists(directoryPath)) + Directory.CreateDirectory(directoryPath); + + string fullPath = $"{saveArchiveFilePath}.cbz"; + if (File.Exists(fullPath)) + return; + string tempFolder = Path.GetTempFileName(); File.Delete(tempFolder); Directory.CreateDirectory(tempFolder); @@ -31,14 +40,7 @@ public abstract class Connector string extension = split[split.Length - 1]; DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}")); } - - string[] splitPath = saveArchiveFilePath.Split(Path.DirectorySeparatorChar); - string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray()); - if (!Directory.Exists(directoryPath)) - Directory.CreateDirectory(directoryPath); - - string fullPath = $"{saveArchiveFilePath}.cbz"; - File.Delete(fullPath); + ZipFile.CreateFromDirectory(tempFolder, fullPath); } diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 8605b27..4ea3e56 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -44,6 +44,8 @@ public class TaskManager if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name && trangaTask.publication?.downloadUrl != publication?.downloadUrl)) { + if(task != TrangaTask.Task.UpdatePublications) + _chapterCollection.Add((Publication)publication!, new List()); _allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language)); ExportTasks(Directory.GetCurrentDirectory()); }