Fixed some errors being thrown when not needed on Cache.Ensure(). Added ability to send actual mangafile information on the volume() api so we can display to the user.
This commit is contained in:
parent
c57b77f092
commit
07fd959b22
10 changed files with 52 additions and 20 deletions
|
@ -20,16 +20,16 @@ namespace API.Comparators
|
|||
if (string.IsNullOrEmpty(s2)) return -1;
|
||||
|
||||
//WE style, special case
|
||||
bool sp1 = Char.IsLetterOrDigit(s1, 0);
|
||||
bool sp2 = Char.IsLetterOrDigit(s2, 0);
|
||||
var sp1 = Char.IsLetterOrDigit(s1, 0);
|
||||
var sp2 = Char.IsLetterOrDigit(s2, 0);
|
||||
if(sp1 && !sp2) return 1;
|
||||
if(!sp1 && sp2) return -1;
|
||||
|
||||
int i1 = 0, i2 = 0; //current index
|
||||
while(true)
|
||||
{
|
||||
bool c1 = Char.IsDigit(s1, i1);
|
||||
bool c2 = Char.IsDigit(s2, i2);
|
||||
var c1 = Char.IsDigit(s1, i1);
|
||||
var c2 = Char.IsDigit(s2, i2);
|
||||
int r; // temp result
|
||||
if(!c1 && !c2)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,13 @@ namespace API.Controllers
|
|||
return Ok(await _unitOfWork.SeriesRepository.GetVolumeDtoAsync(volumeId, user.Id));
|
||||
}
|
||||
|
||||
// [HttpGet("volume-files")]
|
||||
// public async Task<ActionResult<IEnumerable<MangaFileDto>>> GetMangaFiles(int volumeId)
|
||||
// {
|
||||
// var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
|
||||
// return Ok(await _unitOfWork.SeriesRepository.GetVolumeMangaFileDtos(volumeId));
|
||||
// }
|
||||
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
[HttpPost("scan")]
|
||||
public ActionResult Scan(int libraryId, int seriesId)
|
||||
|
|
13
API/DTOs/MangaFileDto.cs
Normal file
13
API/DTOs/MangaFileDto.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using API.Entities;
|
||||
|
||||
namespace API.DTOs
|
||||
{
|
||||
public class MangaFileDto
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
public int Chapter { get; set; }
|
||||
public int NumberOfPages { get; set; }
|
||||
public MangaFormat Format { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace API.DTOs
|
||||
{
|
||||
public class VolumeDto
|
||||
|
@ -9,5 +11,6 @@ namespace API.DTOs
|
|||
public byte[] CoverImage { get; set; }
|
||||
public int Pages { get; set; }
|
||||
public int PagesRead { get; set; }
|
||||
public ICollection<MangaFileDto> Files { get; set; }
|
||||
}
|
||||
}
|
|
@ -15,6 +15,8 @@ namespace API.Helpers
|
|||
|
||||
CreateMap<Volume, VolumeDto>();
|
||||
|
||||
CreateMap<MangaFile, MangaFileDto>();
|
||||
|
||||
CreateMap<Series, SeriesDto>();
|
||||
|
||||
CreateMap<Library, LibraryDto>()
|
||||
|
|
|
@ -25,5 +25,6 @@ namespace API.Interfaces
|
|||
Task<Volume> GetVolumeByIdAsync(int volumeId);
|
||||
Task<Series> GetSeriesByIdAsync(int seriesId);
|
||||
|
||||
//Task<MangaFileDto> GetVolumeMangaFileDtos(int volumeId);
|
||||
}
|
||||
}
|
|
@ -105,28 +105,29 @@ namespace API.Services
|
|||
if (!File.Exists(archivePath) || !Parser.Parser.IsArchive(archivePath))
|
||||
{
|
||||
_logger.LogError($"Archive {archivePath} could not be found.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
_logger.LogDebug($"Archive {archivePath} has already been extracted. Returning existing folder.");
|
||||
return;
|
||||
}
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
using ZipArchive archive = ZipFile.OpenRead(archivePath);
|
||||
// TODO: Throw error if we couldn't extract
|
||||
var needsFlattening = archive.Entries.Count > 0 && !Path.HasExtension(archive.Entries.ElementAt(0).FullName);
|
||||
if (!archive.HasFiles() && !needsFlattening) return;
|
||||
|
||||
archive.ExtractToDirectory(extractPath);
|
||||
_logger.LogDebug($"[OLD] Extracted archive to {extractPath} in {sw.ElapsedMilliseconds} milliseconds.");
|
||||
_logger.LogDebug($"Extracted archive to {extractPath} in {sw.ElapsedMilliseconds} milliseconds.");
|
||||
|
||||
if (needsFlattening)
|
||||
{
|
||||
sw = Stopwatch.StartNew();
|
||||
_logger.LogInformation("Extracted archive is nested in root folder, flattening...");
|
||||
new DirectoryInfo(extractPath).Flatten();
|
||||
_logger.LogInformation($"[OLD] Flattened in {sw.ElapsedMilliseconds} milliseconds");
|
||||
_logger.LogInformation($"Flattened in {sw.ElapsedMilliseconds} milliseconds");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -324,9 +324,19 @@ namespace API.Services
|
|||
}
|
||||
|
||||
_logger.LogDebug($"Getting Page numbers from {archivePath}");
|
||||
|
||||
try
|
||||
{
|
||||
using ZipArchive archive = ZipFile.OpenRead(archivePath); // ZIPFILE
|
||||
return archive.Entries.Count(e => Parser.Parser.IsImage(e.FullName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "There was an exception when reading archive stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
using ZipArchive archive = ZipFile.OpenRead(archivePath); // ZIPFILE
|
||||
return archive.Entries.Count(e => Parser.Parser.IsImage(e.FullName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue