Scanner organization modes (#3203)
* Add BOOK_PER_FILE and BOOK_PER_FOLDER organization modes for library scanning * Filter temp/partial files, support .ignore directories, and skip zero-byte files during scanning * Replace event-based monitoring with WatchService, add pending deletion pool and move detection * Fix folder-based audiobook grouping, improve series detection, and add tests * Add unit tests for BookFileTransactionalHandler, BookFilePersistenceService, and LibraryFileEventProcessor
This commit is contained in:
@@ -3,6 +3,8 @@ import {BookType} from './book.model';
|
||||
|
||||
export type MetadataSource = 'EMBEDDED' | 'SIDECAR' | 'PREFER_SIDECAR' | 'PREFER_EMBEDDED' | 'NONE';
|
||||
|
||||
export type OrganizationMode = 'BOOK_PER_FILE' | 'BOOK_PER_FOLDER' | 'AUTO_DETECT';
|
||||
|
||||
export interface Library {
|
||||
id?: number;
|
||||
name: string;
|
||||
@@ -15,6 +17,7 @@ export interface Library {
|
||||
formatPriority?: BookType[];
|
||||
allowedFormats?: BookType[];
|
||||
metadataSource?: MetadataSource;
|
||||
organizationMode?: OrganizationMode;
|
||||
}
|
||||
|
||||
export interface LibraryPath {
|
||||
|
||||
@@ -151,6 +151,25 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="option-row">
|
||||
<div class="option-label">
|
||||
<span>{{ t('organizationMode') }}</span>
|
||||
<i
|
||||
class="pi pi-question-circle info-icon"
|
||||
[pTooltip]="t('organizationModeTooltip')"
|
||||
tooltipPosition="top"
|
||||
></i>
|
||||
</div>
|
||||
<p-select
|
||||
[(ngModel)]="organizationMode"
|
||||
[options]="organizationModeOptions"
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
class="metadata-source-select"
|
||||
appendTo="body"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="option-divider"></div>
|
||||
|
||||
<div class="option-row option-row-stacked">
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Router} from '@angular/router';
|
||||
import {LibraryService} from '../book/service/library.service';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Library, MetadataSource} from '../book/model/library.model';
|
||||
import {Library, MetadataSource, OrganizationMode} from '../book/model/library.model';
|
||||
import {BookType} from '../book/model/book.model';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
@@ -41,8 +41,10 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
selectedAllowedFormats: Set<BookType> = new Set();
|
||||
formatCounts: Record<string, number> = {};
|
||||
metadataSource: MetadataSource = 'EMBEDDED';
|
||||
organizationMode: OrganizationMode = 'BOOK_PER_FILE';
|
||||
|
||||
metadataSourceOptions: {label: string, value: string}[] = [];
|
||||
organizationModeOptions: {label: string, value: string}[] = [];
|
||||
|
||||
readonly allBookFormats: {type: BookType, label: string}[] = [
|
||||
{type: 'EPUB', label: 'EPUB'},
|
||||
@@ -73,6 +75,7 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
];
|
||||
this.initializeFormatPriority();
|
||||
this.initializeAllowedFormats();
|
||||
this.initializeOrganizationModeOptions();
|
||||
|
||||
const data = this.dynamicDialogConfig?.data;
|
||||
if (data?.mode === 'edit') {
|
||||
@@ -117,6 +120,16 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
this.metadataSource = this.library.metadataSource;
|
||||
}
|
||||
|
||||
if (this.library.organizationMode) {
|
||||
this.organizationMode = this.library.organizationMode;
|
||||
if (this.library.organizationMode === 'AUTO_DETECT') {
|
||||
this.organizationModeOptions.push({
|
||||
label: this.t.translate('libraryCreator.creator.organizationModeAutoDetect'),
|
||||
value: 'AUTO_DETECT'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.libraryService.getBookCountsByFormat(this.library.id!).subscribe(counts => {
|
||||
this.formatCounts = counts;
|
||||
});
|
||||
@@ -130,6 +143,13 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
this.formatPriority = [...this.allBookFormats];
|
||||
}
|
||||
|
||||
private initializeOrganizationModeOptions(): void {
|
||||
this.organizationModeOptions = [
|
||||
{label: this.t.translate('libraryCreator.creator.organizationModeBookPerFile'), value: 'BOOK_PER_FILE'},
|
||||
{label: this.t.translate('libraryCreator.creator.organizationModeBookPerFolder'), value: 'BOOK_PER_FOLDER'}
|
||||
];
|
||||
}
|
||||
|
||||
private initializeAllowedFormats(): void {
|
||||
this.selectedAllowedFormats = new Set(this.allBookFormats.map(f => f.type));
|
||||
}
|
||||
@@ -237,7 +257,8 @@ export class LibraryCreatorComponent implements OnInit {
|
||||
watch: this.watch,
|
||||
formatPriority: this.formatPriority.map(f => f.type),
|
||||
allowedFormats: this.allowAllFormats ? [] : Array.from(this.selectedAllowedFormats),
|
||||
metadataSource: this.metadataSource
|
||||
metadataSource: this.metadataSource,
|
||||
organizationMode: this.organizationMode
|
||||
};
|
||||
|
||||
if (this.mode === 'edit') {
|
||||
|
||||
Reference in New Issue
Block a user