Polish Round 2 (#2411)

This commit is contained in:
Joe Milazzo 2023-11-07 17:42:17 -06:00 committed by GitHub
parent ba3e760b31
commit a2fd87c454
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 213 additions and 95 deletions

View file

@ -687,7 +687,7 @@ public class AccountController : BaseApiController
if (!_emailService.IsValidEmail(dto.Email))
{
_logger.LogInformation("[Invite User] {Email} doesn't appear to be an email, so will not send an email to address", dto.Email);
_logger.LogInformation("[Invite User] {Email} doesn't appear to be an email, so will not send an email to address", dto.Email.Replace(Environment.NewLine, string.Empty));
return Ok(new InviteUserResponse
{
EmailLink = emailLink,

View file

@ -59,7 +59,7 @@ public class CollectionController : BaseApiController
/// <returns></returns>
[Authorize(Policy = "RequireAdminRole")]
[HttpGet("search")]
public async Task<ActionResult<IEnumerable<CollectionTagDto>>> SearchTags(string queryString)
public async Task<ActionResult<IEnumerable<CollectionTagDto>>> SearchTags(string? queryString)
{
queryString ??= string.Empty;
queryString = queryString.Replace(@"%", string.Empty);

View file

@ -134,7 +134,7 @@ public class LibraryController : BaseApiController
/// <returns></returns>
[Authorize(Policy = "RequireAdminRole")]
[HttpGet("list")]
public ActionResult<IEnumerable<DirectoryDto>> GetDirectories(string path)
public ActionResult<IEnumerable<DirectoryDto>> GetDirectories(string? path)
{
if (string.IsNullOrEmpty(path))
{
@ -385,7 +385,7 @@ public class LibraryController : BaseApiController
}
catch (Exception ex)
{
_logger.LogError(ex, await _localizationService.Translate(User.GetUserId(), "generic-library"));
_logger.LogError(ex, "There was a critical issue. Please try again");
await _unitOfWork.RollbackAsync();
return Ok(false);
}
@ -441,7 +441,7 @@ public class LibraryController : BaseApiController
// Override Scrobbling for Comic libraries since there are no providers to scrobble to
if (library.Type == LibraryType.Comic)
{
_logger.LogInformation("Overrode Library {Name} to disable scrobbling since there are no providers for Comics", dto.Name);
_logger.LogInformation("Overrode Library {Name} to disable scrobbling since there are no providers for Comics", dto.Name.Replace(Environment.NewLine, string.Empty));
library.AllowScrobbling = false;
}
@ -471,7 +471,11 @@ public class LibraryController : BaseApiController
}
/// <summary>
/// Returns the type of the underlying library
/// </summary>
/// <param name="libraryId"></param>
/// <returns></returns>
[HttpGet("type")]
public async Task<ActionResult<LibraryType>> GetLibraryType(int libraryId)
{

View file

@ -46,7 +46,7 @@ public class PluginController : BaseApiController
var userId = await _unitOfWork.UserRepository.GetUserIdByApiKeyAsync(apiKey);
if (userId <= 0)
{
_logger.LogInformation("A Plugin ({PluginName}) tried to authenticate with an apiKey that doesn't match. Information {@Information}", Uri.EscapeDataString(pluginName), new
_logger.LogInformation("A Plugin ({PluginName}) tried to authenticate with an apiKey that doesn't match. Information {@Information}", pluginName.Replace(Environment.NewLine, string.Empty), new
{
IpAddress = ipAddress,
UserAgent = userAgent,
@ -55,7 +55,7 @@ public class PluginController : BaseApiController
throw new KavitaUnauthenticatedUserException();
}
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);
_logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", Uri.EscapeDataString(pluginName), user!.UserName, userId);
_logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId);
return new UserDto
{
Username = user.UserName!,

View file

@ -230,6 +230,8 @@ public class ReaderController : BaseApiController
if (dto == null) return BadRequest(await _localizationService.Translate(User.GetUserId(), "perform-scan"));
var mangaFile = chapter.Files.First();
var series = await _unitOfWork.SeriesRepository.GetSeriesDtoByIdAsync(dto.SeriesId, User.GetUserId());
var info = new ChapterInfoDto()
{
ChapterNumber = dto.ChapterNumber,
@ -242,6 +244,8 @@ public class ReaderController : BaseApiController
LibraryId = dto.LibraryId,
IsSpecial = dto.IsSpecial,
Pages = dto.Pages,
SeriesTotalPages = series?.Pages ?? 0,
SeriesTotalPagesRead = series?.PagesRead ?? 0,
ChapterTitle = dto.ChapterTitle ?? string.Empty,
Subtitle = string.Empty,
Title = dto.SeriesName,
@ -266,8 +270,7 @@ public class ReaderController : BaseApiController
}
else
{
//info.Subtitle = await _localizationService.Translate(User.GetUserId(), "volume-num", info.VolumeNumber);
info.Subtitle = $"Volume {info.VolumeNumber}";
info.Subtitle = await _localizationService.Translate(User.GetUserId(), "volume-num", info.VolumeNumber);
if (!info.ChapterNumber.Equals(Services.Tasks.Scanner.Parser.Parser.DefaultChapter))
{
info.Subtitle += " " + ReaderService.FormatChapterName(info.LibraryType, true, true) +

View file

@ -143,7 +143,7 @@ public class SeriesController : BaseApiController
public async Task<ActionResult> DeleteMultipleSeries(DeleteSeriesDto dto)
{
var username = User.GetUsername();
_logger.LogInformation("Series {SeriesId} is being deleted by {UserName}", dto.SeriesIds, username);
_logger.LogInformation("Series {@SeriesId} is being deleted by {UserName}", dto.SeriesIds, username);
if (await _seriesService.DeleteMultipleSeries(dto.SeriesIds)) return Ok();

View file

@ -65,6 +65,14 @@ public class ChapterInfoDto : IChapterInfoDto
/// </summary>
/// <remarks>Usually just series name, but can include chapter title</remarks>
public string Title { get; set; } = default!;
/// <summary>
/// Total pages for the series
/// </summary>
public int SeriesTotalPages { get; set; }
/// <summary>
/// Total pages read for the series
/// </summary>
public int SeriesTotalPagesRead { get; set; }
/// <summary>
/// List of all files with their inner archive structure maintained in filename and dimensions
@ -76,5 +84,4 @@ public class ChapterInfoDto : IChapterInfoDto
/// </summary>
/// <remarks>This is optionally returned by includeDimensions</remarks>
public IDictionary<int, int>? DoublePairs { get; set; }
}

View file

@ -369,6 +369,7 @@ public class DirectoryService : IDirectoryService
/// <returns></returns>
public void ClearDirectory(string directoryPath)
{
directoryPath = directoryPath.Replace(Environment.NewLine, string.Empty);
var di = FileSystem.DirectoryInfo.New(directoryPath);
if (!di.Exists) return;
try

View file

@ -219,7 +219,7 @@ public class ImageService : IImageService
{
// Parse the URL to get the domain (including subdomain)
var uri = new Uri(url);
var domain = uri.Host;
var domain = uri.Host.Replace(Environment.NewLine, string.Empty);
var baseUrl = uri.Scheme + "://" + uri.Host;

View file

@ -158,10 +158,14 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
{
// This compares if it's changed since a file scan only
var firstFile = chapter.Files.FirstOrDefault();
if (firstFile == null) return;
if (!_cacheHelper.HasFileChangedSinceLastScan(firstFile.LastFileAnalysis, forceUpdate,
if (firstFile == null || !_cacheHelper.HasFileChangedSinceLastScan(firstFile.LastFileAnalysis,
forceUpdate,
firstFile))
{
volume.WordCount += chapter.WordCount;
series.WordCount += chapter.WordCount;
continue;
}
if (series.Format == MangaFormat.Epub)
{

View file

@ -306,7 +306,7 @@ public class ProcessSeries : IProcessSeries
if (!series.Metadata.PublicationStatusLocked)
{
series.Metadata.PublicationStatus = PublicationStatus.OnGoing;
if (series.Metadata.MaxCount >= series.Metadata.TotalCount && series.Metadata.TotalCount > 0)
if (series.Metadata.MaxCount == series.Metadata.TotalCount && series.Metadata.TotalCount > 0)
{
series.Metadata.PublicationStatus = PublicationStatus.Completed;
} else if (series.Metadata.TotalCount > 0)