Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Shakeout Part 2 (#630)
Joseph Milazzo3907414ae45e
diff --git a/API.Tests/Parser/BookParserTests.cs b/API.Tests/Parser/BookParserTests.csindex 219f5d723..b33ef1f54 100644--- a/API.Tests/Parser/BookParserTests.cs+++ b/API.Tests/Parser/BookParserTests.cs@@ -10,5 +10,12 @@ namespace API.Tests.Parser{Assert.Equal(expected, API.Parser.Parser.ParseSeries(filename));}++ [Theory]+ [InlineData("Harrison, Kim - Dates from Hell - Hollows Vol 2.5.epub", "2.5")]+ public void ParseVolumeTest(string filename, string expected)+ {+ Assert.Equal(expected, API.Parser.Parser.ParseVolume(filename));+ }}}diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.csindex 7fb204ca7..9cb9d560a 100644--- a/API.Tests/Parser/MangaParserTests.cs+++ b/API.Tests/Parser/MangaParserTests.cs@@ -239,6 +239,7 @@ namespace API.Tests.Parser[InlineData("Kimi no Koto ga Daidaidaidaidaisuki na 100-nin no Kanojo Chapter 1-10", "1-10")][InlineData("Deku_&_Bakugo_-_Rising_v1_c1.1.cbz", "1.1")][InlineData("Chapter 63 - The Promise Made for 520 Cenz.cbr", "63")]+ [InlineData("Harrison, Kim - The Good, The Bad, and the Undead - Hollows Vol 2.5.epub", "0")]public void ParseChaptersTest(string filename, string expected){Assert.Equal(expected, API.Parser.Parser.ParseChapter(filename));@@ -425,6 +426,14 @@ namespace API.Tests.ParserFullFilePath = filepath, IsSpecial = false});+ filepath = @"E:\Manga\Harrison, Kim - The Good, The Bad, and the Undead - Hollows Vol 2.5.epub";+ expected.Add(filepath, new ParserInfo+ {+ Series = "Harrison, Kim - The Good, The Bad, and the Undead - Hollows", Volumes = "2.5", Edition = "",+ Chapters = "0", Filename = "Harrison, Kim - The Good, The Bad, and the Undead - Hollows Vol 2.5.epub", Format = MangaFormat.Epub,+ FullFilePath = filepath, IsSpecial = false+ });+// If an image is cover exclusively, ignore itfilepath = @"E:\Manga\Seraph of the End\cover.png";expected.Add(filepath, null);diff --git a/API/Extensions/DirectoryInfoExtensions.cs b/API/Extensions/DirectoryInfoExtensions.csindex 892c690b3..b92901046 100644--- a/API/Extensions/DirectoryInfoExtensions.cs+++ b/API/Extensions/DirectoryInfoExtensions.cs@@ -76,7 +76,8 @@ namespace API.ExtensionsdirectoryIndex++;}- foreach (var subDirectory in directory.EnumerateDirectories())+ var sort = new NaturalSortComparer();+ foreach (var subDirectory in directory.EnumerateDirectories().OrderBy(d => d.FullName, sort)){FlattenDirectory(root, subDirectory, ref directoryIndex);}diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.csindex 5c9c22f83..ef2d9ef5d 100644--- a/API/Parser/Parser.cs+++ b/API/Parser/Parser.cs@@ -470,7 +470,7 @@ namespace API.ParserRegexTimeout),// Hinowa ga CRUSH! 018 (2019) (Digital) (LuCaZ).cbz, Hinowa ga CRUSH! 018.5 (2019) (Digital) (LuCaZ).cbznew Regex(- @"^(?!Vol)(?<Series>.+?)\s(?<!vol\. )(?<Chapter>\d+(?:.\d+|-\d+)?)(?:\s\(\d{4}\))?(\b|_|-)",+ @"^(?!Vol)(?<Series>.+?)(?<!Vol)\.?\s(?<Chapter>\d+(?:.\d+|-\d+)?)(?:\s\(\d{4}\))?(\b|_|-)",MatchOptions,RegexTimeout),// Tower Of God S01 014 (CBT) (digital).cbzdiff --git a/API/Services/Tasks/ScannerService.cs b/API/Services/Tasks/ScannerService.csindex 0701fe13f..f1ba9cc59 100644--- a/API/Services/Tasks/ScannerService.cs+++ b/API/Services/Tasks/ScannerService.cs@@ -73,8 +73,17 @@ namespace API.Services.Tasksif (!anyFilesExist){- _unitOfWork.SeriesRepository.Remove(series);- await CommitAndSend(libraryId, seriesId, totalFiles, parsedSeries, sw, scanElapsedTime, series, chapterIds, token);+ try+ {+ _unitOfWork.SeriesRepository.Remove(series);+ await CommitAndSend(libraryId, seriesId, totalFiles, parsedSeries, sw, scanElapsedTime, series, chapterIds);+ }+ catch (Exception ex)+ {+ _logger.LogCritical(ex, "There was an error during ScanSeries to delete the series");+ await _unitOfWork.RollbackAsync();+ }+}else{@@ -97,7 +106,7 @@ namespace API.Services.Tasks}}- _logger.LogInformation("{SeriesName} has bad naming convention, forcing rescan at a higher directory.", series.OriginalName);+ _logger.LogInformation("{SeriesName} has bad naming convention, forcing rescan at a higher directory", series.OriginalName);scanner = new ParseScannedFiles(_bookService, _logger);parsedSeries = scanner.ScanLibrariesForSeries(library.Type, dirs.Keys, out var totalFiles2, out var scanElapsedTime2);totalFiles += totalFiles2;@@ -109,8 +118,19 @@ namespace API.Services.Tasks// At this point, parsedSeries will have at least one key and we can perform the update. If it still doesn't, just return and don't do anythingif (parsedSeries.Count == 0) return;- UpdateSeries(series, parsedSeries);- await CommitAndSend(libraryId, seriesId, totalFiles, parsedSeries, sw, scanElapsedTime, series, chapterIds, token);+ try+ {+ UpdateSeries(series, parsedSeries);+ await CommitAndSend(libraryId, seriesId, totalFiles, parsedSeries, sw, scanElapsedTime, series, chapterIds);+ }+ catch (Exception ex)+ {+ _logger.LogCritical(ex, "There was an error during ScanSeries to update the series");+ await _unitOfWork.RollbackAsync();+ }+ // Tell UI that this series is done+ await _messageHub.Clients.All.SendAsync(SignalREvents.ScanSeries, MessageFactory.ScanSeriesEvent(seriesId, series.Name),+ cancellationToken: token);}private static void RemoveParsedInfosNotForSeries(Dictionary<ParsedSeries, List<ParserInfo>> parsedSeries, Series series)@@ -124,10 +144,11 @@ namespace API.Services.Tasks}private async Task CommitAndSend(int libraryId, int seriesId, int totalFiles,- Dictionary<ParsedSeries, List<ParserInfo>> parsedSeries, Stopwatch sw, long scanElapsedTime, Series series, int[] chapterIds, CancellationToken token)+ Dictionary<ParsedSeries, List<ParserInfo>> parsedSeries, Stopwatch sw, long scanElapsedTime, Series series, int[] chapterIds){- if (await _unitOfWork.CommitAsync())+ if (_unitOfWork.HasChanges()){+ await _unitOfWork.CommitAsync();_logger.LogInformation("Processed {TotalFiles} files and {ParsedSeriesCount} series in {ElapsedScanTime} milliseconds for {SeriesName}",totalFiles, parsedSeries.Keys.Count, sw.ElapsedMilliseconds + scanElapsedTime, series.Name);@@ -135,15 +156,6 @@ namespace API.Services.Tasksawait CleanupDbEntities();BackgroundJob.Enqueue(() => _metadataService.RefreshMetadataForSeries(libraryId, seriesId, false));BackgroundJob.Enqueue(() => _cacheService.CleanupChapters(chapterIds));- // Tell UI that this series is done- await _messageHub.Clients.All.SendAsync(SignalREvents.ScanSeries, MessageFactory.ScanSeriesEvent(seriesId, series.Name),- cancellationToken: token);- }- else- {- _logger.LogCritical(- "There was a critical error that resulted in a failed scan. Please check logs and rescan");- await _unitOfWork.RollbackAsync();}}diff --git a/UI/Web/src/app/admin/_modals/reset-password-modal/reset-password-modal.component.html b/UI/Web/src/app/admin/_modals/reset-password-modal/reset-password-modal.component.htmlindex c7f16ebef..323f4b35f 100644--- a/UI/Web/src/app/admin/_modals/reset-password-modal/reset-password-modal.component.html+++ b/UI/Web/src/app/admin/_modals/reset-password-modal/reset-password-modal.component.html@@ -1,6 +1,6 @@<form [formGroup]="resetPasswordForm"><div class="modal-header">- <h4 class="modal-title" id="modal-basic-title">Reset {{member.username | titlecase}}'s Password</h4>+ <h4 class="modal-title" id="modal-basic-title">Reset {{member.username | sentenceCase}}'s Password</h4><button type="button" class="close" aria-label="Close" (click)="close()"><span aria-hidden="true">×</span></button>diff --git a/UI/Web/src/app/admin/dashboard/dashboard.component.html b/UI/Web/src/app/admin/dashboard/dashboard.component.htmlindex 9b34f71f8..fdf09ea33 100644--- a/UI/Web/src/app/admin/dashboard/dashboard.component.html+++ b/UI/Web/src/app/admin/dashboard/dashboard.component.html@@ -3,7 +3,7 @@<ul ngbNav #nav="ngbNav" [(activeId)]="active" class="nav-tabs nav-pills"><li *ngFor="let tab of tabs" [ngbNavItem]="tab">- <a ngbNavLink routerLink="." [fragment]="tab.fragment">{{ tab.title | titlecase }}</a>+ <a ngbNavLink routerLink="." [fragment]="tab.fragment">{{ tab.title | sentenceCase }}</a><ng-template ngbNavContent><ng-container *ngIf="tab.fragment === ''"><app-manage-settings></app-manage-settings>diff --git a/UI/Web/src/app/admin/manage-library/manage-library.component.html b/UI/Web/src/app/admin/manage-library/manage-library.component.htmlindex 869c2cf99..a13c1286d 100644--- a/UI/Web/src/app/admin/manage-library/manage-library.component.html+++ b/UI/Web/src/app/admin/manage-library/manage-library.component.html@@ -4,7 +4,7 @@<div class="col-4"><button class="btn btn-primary float-right" (click)="addLibrary()"><i class="fa fa-plus" aria-hidden="true"></i><span class="phone-hidden"> Add Library</span></button></div></div><ul class="list-group" *ngIf="!createLibraryToggle; else createLibrary">- <li *ngFor="let library of libraries; let idx = index;" class="list-group-item">+ <li *ngFor="let library of libraries; let idx = index; trackby: trackbyLibrary" class="list-group-item"><div><h4><span id="library-name--{{idx}}">{{library.name}}</span> @@ -13,8 +13,8 @@</div><div class="float-right"><button class="btn btn-secondary mr-2 btn-sm" (click)="scanLibrary(library)" placement="top" ngbTooltip="Scan Library" attr.aria-label="Scan Library"><i class="fa fa-sync-alt" title="Scan"></i></button>- <button class="btn btn-danger mr-2 btn-sm" [disabled]="deletionInProgress" (click)="deleteLibrary(library)"><i class="fa fa-trash" placement="top" ngbTooltip="Delete Library" attr.aria-label="Delete {{library.name | titlecase}}"></i></button>- <button class="btn btn-primary btn-sm" (click)="editLibrary(library)"><i class="fa fa-pen" placement="top" ngbTooltip="Edit" attr.aria-label="Edit {{library.name | titlecase}}"></i></button>+ <button class="btn btn-danger mr-2 btn-sm" [disabled]="deletionInProgress" (click)="deleteLibrary(library)"><i class="fa fa-trash" placement="top" ngbTooltip="Delete Library" attr.aria-label="Delete {{library.name | sentenceCase}}"></i></button>+ <button class="btn btn-primary btn-sm" (click)="editLibrary(library)"><i class="fa fa-pen" placement="top" ngbTooltip="Edit" attr.aria-label="Edit {{library.name | sentenceCase}}"></i></button></div></h4></div>diff --git a/UI/Web/src/app/admin/manage-library/manage-library.component.ts b/UI/Web/src/app/admin/manage-library/manage-library.component.tsindex 36d5db3f9..7ba0c87b8 100644--- a/UI/Web/src/app/admin/manage-library/manage-library.component.ts+++ b/UI/Web/src/app/admin/manage-library/manage-library.component.ts@@ -25,6 +25,7 @@ export class ManageLibraryComponent implements OnInit, OnDestroy {*/deletionInProgress: boolean = false;scanInProgress: {[key: number]: boolean} = {};+ libraryTrackBy = (index: number, item: Library) => `${item.name}_${item.lastScanned}_${item.type}_${item.folders.length}`;private readonly onDestroy = new Subject<void>();diff --git a/UI/Web/src/app/admin/manage-users/manage-users.component.html b/UI/Web/src/app/admin/manage-users/manage-users.component.htmlindex 2f54e76ef..5b6ce57b9 100644--- a/UI/Web/src/app/admin/manage-users/manage-users.component.html+++ b/UI/Web/src/app/admin/manage-users/manage-users.component.html@@ -19,7 +19,7 @@<div>Last Active:<span *ngIf="member.lastActive == '0001-01-01T00:00:00'; else activeDate">Never</span><ng-template #activeDate>- {{member.lastActive | date: 'MM/dd/yyyy'}}+ {{member.lastActive | date: 'short'}}</ng-template></div><div *ngIf="!member.isAdmin">Sharing: {{formatLibraries(member)}}</div>diff --git a/UI/Web/src/app/cards/_modals/card-details-modal/card-details-modal.component.html b/UI/Web/src/app/cards/_modals/card-details-modal/card-details-modal.component.htmlindex d18987f6b..85e17f125 100644--- a/UI/Web/src/app/cards/_modals/card-details-modal/card-details-modal.component.html+++ b/UI/Web/src/app/cards/_modals/card-details-modal/card-details-modal.component.html@@ -19,7 +19,7 @@</div><div class="row no-gutters"><div class="col" *ngIf="utilityService.isVolume(data)">- Added: {{(data.created | date: 'MM/dd/yyyy') || '-'}}+ Added: {{(data.created | date: 'short') || '-'}}</div><div class="col">Pages: {{data.pages}}diff --git a/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.html b/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.htmlindex c354ac22d..f39ee04d1 100644--- a/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.html+++ b/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.html@@ -95,7 +95,7 @@<ng-template ngbNavContent><h4>Information</h4><div class="row no-gutters mb-2">- <div class="col-md-6" *ngIf="libraryName">Library: {{libraryName | titlecase}}</div>+ <div class="col-md-6" *ngIf="libraryName">Library: {{libraryName | sentenceCase}}</div><div class="col-md-6">Format: <app-tag-badge>{{utilityService.mangaFormat(series.format)}}</app-tag-badge></div></div><h4>Volumes</h4>@@ -110,10 +110,10 @@<div><div class="row no-gutters"><div class="col">- Created: {{volume.created | date: 'MM/dd/yyyy'}}+ Created: {{volume.created | date: 'short'}}</div><div class="col">- Last Modified: {{volume.lastModified | date: 'MM/dd/yyyy'}}+ Last Modified: {{volume.lastModified | date: 'short'}}</div></div><div class="row no-gutters">diff --git a/UI/Web/src/app/cards/card-item/card-item.component.html b/UI/Web/src/app/cards/card-item/card-item.component.htmlindex 5f42ecf65..7fee96b23 100644--- a/UI/Web/src/app/cards/card-item/card-item.component.html+++ b/UI/Web/src/app/cards/card-item/card-item.component.html@@ -38,6 +38,6 @@<app-card-actionables (actionHandler)="performAction($event)" [actions]="actions" [labelBy]="title"></app-card-actionables></span></div>- <a class="card-title library" [routerLink]="['/library', libraryId]" routerLinkActive="router-link-active" *ngIf="!supressLibraryLink && libraryName">{{libraryName}}</a>+ <a class="card-title library" [routerLink]="['/library', libraryId]" routerLinkActive="router-link-active" *ngIf="!supressLibraryLink && libraryName">{{libraryName | sentenceCase}}</a></div></div>\ No newline at end of filediff --git a/UI/Web/src/app/manga-reader/manga-reader.component.html b/UI/Web/src/app/manga-reader/manga-reader.component.htmlindex 0a96cadd0..698596fb5 100644--- a/UI/Web/src/app/manga-reader/manga-reader.component.html+++ b/UI/Web/src/app/manga-reader/manga-reader.component.html@@ -31,8 +31,8 @@<app-infinite-scroller [pageNum]="pageNum" [bufferPages]="5" [goToPage]="goToPageEvent" (pageNumberChange)="handleWebtoonPageChange($event)" [totalPages]="maxPages - 1" [urlProvider]="getPageUrl" (loadNextChapter)="loadNextChapter()" (loadPrevChapter)="loadPrevChapter()"></app-infinite-scroller></div><ng-container *ngIf="readerMode === READER_MODE.MANGA_LR || readerMode === READER_MODE.MANGA_UD">- <div class="{{readerMode === READER_MODE.MANGA_LR ? 'right' : 'top'}} {{clickOverlayClass('right')}}" (click)="handlePageChange($event, 'right')"></div>- <div class="{{readerMode === READER_MODE.MANGA_LR ? 'left' : 'bottom'}} {{clickOverlayClass('left')}}" (click)="handlePageChange($event, 'left')"></div>+ <div class="{{readerMode === READER_MODE.MANGA_LR ? 'right' : 'bottom'}} {{clickOverlayClass('right')}}" (click)="handlePageChange($event, 'right')"></div>+ <div class="{{readerMode === READER_MODE.MANGA_LR ? 'left' : 'top'}} {{clickOverlayClass('left')}}" (click)="handlePageChange($event, 'left')"></div></ng-container></div>diff --git a/UI/Web/src/app/nav-header/nav-header.component.html b/UI/Web/src/app/nav-header/nav-header.component.htmlindex c371393d3..87bc92ec5 100644--- a/UI/Web/src/app/nav-header/nav-header.component.html+++ b/UI/Web/src/app/nav-header/nav-header.component.html@@ -63,7 +63,7 @@<div ngbDropdown class="nav-item dropdown" display="dynamic" placement="bottom-right" *ngIf="(accountService.currentUser$ | async) as user" dropdown><button class="btn btn-outline-secondary primary-text" ngbDropdownToggle>- {{user.username | titlecase}}+ {{user.username | sentenceCase}}</button><div ngbDropdownMenu><a ngbDropdownItem routerLink="/preferences/">User Settings</a>diff --git a/UI/Web/src/app/register-member/register-member.component.scss b/UI/Web/src/app/register-member/register-member.component.scssindex 74ab28f75..485525296 100644--- a/UI/Web/src/app/register-member/register-member.component.scss+++ b/UI/Web/src/app/register-member/register-member.component.scss@@ -10,4 +10,8 @@.alt:focus {background-color: #343c59;box-shadow: 0 0 0 0.2rem rgb(68 79 117 / 50%);+}++input {+ background-color: #fff !important;}\ No newline at end of filediff --git a/UI/Web/src/app/shared/sentence-case.pipe.ts b/UI/Web/src/app/shared/sentence-case.pipe.tsnew file mode 100644index 000000000..49930a6d5--- /dev/null+++ b/UI/Web/src/app/shared/sentence-case.pipe.ts@@ -0,0 +1,14 @@+import { Pipe, PipeTransform } from '@angular/core';++@Pipe({+ name: 'sentenceCase'+})+export class SentenceCasePipe implements PipeTransform {++ transform(value: string | null): string {+ if (value === null || value === undefined) return '';++ return value.charAt(0).toUpperCase() + value.substr(1);+ }++}diff --git a/UI/Web/src/app/shared/shared.module.ts b/UI/Web/src/app/shared/shared.module.tsindex 246d9363c..efd0dc009 100644--- a/UI/Web/src/app/shared/shared.module.ts+++ b/UI/Web/src/app/shared/shared.module.ts@@ -15,6 +15,7 @@ import { SeriesFormatComponent } from './series-format/series-format.component';import { UpdateNotificationModalComponent } from './update-notification/update-notification-modal.component';import { CircularLoaderComponent } from './circular-loader/circular-loader.component';import { NgCircleProgressModule } from 'ng-circle-progress';+import { SentenceCasePipe } from './sentence-case.pipe';@NgModule({declarations: [@@ -29,6 +30,7 @@ import { NgCircleProgressModule } from 'ng-circle-progress';SeriesFormatComponent,UpdateNotificationModalComponent,CircularLoaderComponent,+ SentenceCasePipe,],imports: [CommonModule,@@ -40,6 +42,7 @@ import { NgCircleProgressModule } from 'ng-circle-progress';exports: [RegisterMemberComponent,SafeHtmlPipe,+ SentenceCasePipe,ReadMoreComponent,DrawerComponent,TagBadgeComponent,diff --git a/UI/Web/src/app/user-login/user-login.component.html b/UI/Web/src/app/user-login/user-login.component.htmlindex bd2d6c048..9caa02e73 100644--- a/UI/Web/src/app/user-login/user-login.component.html+++ b/UI/Web/src/app/user-login/user-login.component.html@@ -15,7 +15,7 @@<div class="col align-self-center card p-3 m-3" style="width: 12rem;"><span tabindex="0" (click)="select(member)" a11y-click="13,32"><div class="logo-container">- <h3 class="card-title text-center">{{member | titlecase}}</h3>+ <h3 class="card-title text-center">{{member | sentenceCase}}</h3></div></span>diff --git a/UI/Web/src/app/user-login/user-login.component.scss b/UI/Web/src/app/user-login/user-login.component.scssindex 3fc84bd80..85a3f61dc 100644--- a/UI/Web/src/app/user-login/user-login.component.scss+++ b/UI/Web/src/app/user-login/user-login.component.scss@@ -55,10 +55,6 @@.card-text {font-family: "EBGaramond", "Helvetica Neue", sans-serif;-- input {- background-color: #fff;- }}.alt {@@ -80,4 +76,8 @@.invalid-feedback {display: inline-block;color: #343c59;+}++input {+ background-color: #fff !important;}\ No newline at end of file