From 70cc163cb01c919ef5f2cd07ddb2be57f3930e41 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Tue, 23 Mar 2021 14:41:14 -0500 Subject: [PATCH] More cleanup --- API/Data/SeriesRepository.cs | 3 +-- API/Interfaces/Services/IArchiveService.cs | 2 +- API/Services/ArchiveService.cs | 15 ++++----------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/API/Data/SeriesRepository.cs b/API/Data/SeriesRepository.cs index 73b49ef1e..84b904b51 100644 --- a/API/Data/SeriesRepository.cs +++ b/API/Data/SeriesRepository.cs @@ -204,8 +204,7 @@ namespace API.Data .Include(s => s.Volumes) .ThenInclude(v => v.Chapters) .ToListAsync(); - - // TODO: refactor this + IList chapterIds = new List(); foreach (var s in series) { diff --git a/API/Interfaces/Services/IArchiveService.cs b/API/Interfaces/Services/IArchiveService.cs index 640991db6..aa5df49e2 100644 --- a/API/Interfaces/Services/IArchiveService.cs +++ b/API/Interfaces/Services/IArchiveService.cs @@ -7,7 +7,7 @@ namespace API.Interfaces.Services { void ExtractArchive(string archivePath, string extractPath); int GetNumberOfPagesFromArchive(string archivePath); - byte[] GetCoverImage(string filepath, bool createThumbnail = false); + byte[] GetCoverImage(string archivePath, bool createThumbnail = false); bool IsValidArchive(string archivePath); string GetSummaryInfo(string archivePath); ArchiveLibrary CanOpen(string archivePath); diff --git a/API/Services/ArchiveService.cs b/API/Services/ArchiveService.cs index 960fa2627..c10517d82 100644 --- a/API/Services/ArchiveService.cs +++ b/API/Services/ArchiveService.cs @@ -42,7 +42,6 @@ namespace API.Services { using var a2 = ZipFile.OpenRead(archivePath); return ArchiveLibrary.Default; - } catch (Exception) { @@ -65,10 +64,7 @@ namespace API.Services _logger.LogError("Archive {ArchivePath} could not be found", archivePath); return 0; } - var count = 0; - - try { var libraryHandler = CanOpen(archivePath); @@ -316,14 +312,12 @@ namespace API.Services break; } case ArchiveLibrary.NotSupported: - _logger.LogError("[GetNumberOfPagesFromArchive] This archive cannot be read: {ArchivePath}. Defaulting to 0 pages", archivePath); + _logger.LogError("[GetSummaryInfo] This archive cannot be read: {ArchivePath}. Defaulting to 0 pages", archivePath); return summary; default: - _logger.LogError("[GetNumberOfPagesFromArchive] There was an exception when reading archive stream: {ArchivePath}. Defaulting to 0 pages", archivePath); + _logger.LogError("[GetSummaryInfo] There was an exception when reading archive stream: {ArchivePath}. Defaulting to 0 pages", archivePath); return summary; } - - if (info != null) { @@ -340,7 +334,7 @@ namespace API.Services return summary; } - private void ExtractArchiveEntities(IEnumerable entries, string extractPath) + private static void ExtractArchiveEntities(IEnumerable entries, string extractPath) { DirectoryService.ExistOrCreate(extractPath); foreach (var entry in entries) @@ -390,7 +384,7 @@ namespace API.Services case ArchiveLibrary.Default: { _logger.LogDebug("Using default compression handling"); - using ZipArchive archive = ZipFile.OpenRead(archivePath); + using var archive = ZipFile.OpenRead(archivePath); ExtractArchiveEntries(archive, extractPath); break; } @@ -418,5 +412,4 @@ namespace API.Services _logger.LogDebug("Extracted archive to {ExtractPath} in {ElapsedMilliseconds} milliseconds", extractPath, sw.ElapsedMilliseconds); } } - } \ No newline at end of file