From 83076f02adcd15f5cc2e3e5c6716083a2e8d7004 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Tue, 12 Jan 2021 14:09:20 -0600 Subject: [PATCH] Forgot to update DTO to send it to the Frontend. --- API/DTOs/VolumeDto.cs | 1 + API/Interfaces/ICacheService.cs | 1 + API/Services/CacheService.cs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/API/DTOs/VolumeDto.cs b/API/DTOs/VolumeDto.cs index dcc4eb258..33ed702c8 100644 --- a/API/DTOs/VolumeDto.cs +++ b/API/DTOs/VolumeDto.cs @@ -7,5 +7,6 @@ namespace API.DTOs public int Number { get; set; } public string Name { get; set; } public byte[] CoverImage { get; set; } + public int Pages { get; set; } } } \ No newline at end of file diff --git a/API/Interfaces/ICacheService.cs b/API/Interfaces/ICacheService.cs index 695f0adc6..57d6a4c11 100644 --- a/API/Interfaces/ICacheService.cs +++ b/API/Interfaces/ICacheService.cs @@ -23,6 +23,7 @@ namespace API.Interfaces /// Clears cache directory of all volumes that belong to a given library. /// /// + /// Volumes that belong to that library. Assume the library might have been deleted before this invocation. void CleanupLibrary(int libraryId, int[] volumeIds); diff --git a/API/Services/CacheService.cs b/API/Services/CacheService.cs index 848ebfc16..7a7ba1acf 100644 --- a/API/Services/CacheService.cs +++ b/API/Services/CacheService.cs @@ -26,8 +26,18 @@ namespace API.Services _numericComparer = new NumericComparer(); } + private bool CacheDirectoryIsAccessible() + { + var di = new DirectoryInfo(_cacheDirectory); + return di.Exists; + } + public async Task Ensure(int volumeId) { + if (!CacheDirectoryIsAccessible()) + { + return null; + } Volume volume = await _seriesRepository.GetVolumeAsync(volumeId); foreach (var file in volume.Files) { @@ -44,6 +54,12 @@ namespace API.Services { _logger.LogInformation("Performing cleanup of Cache directory"); + if (!CacheDirectoryIsAccessible()) + { + _logger.LogError($"Cache directory {_cacheDirectory} is not accessible or does not exist."); + return; + } + DirectoryInfo di = new DirectoryInfo(_cacheDirectory); try