Stream CBZ contents directly from the archive instead of unzipping and caching files (#2229)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-10 10:41:34 -07:00
committed by GitHub
co-authored by acx10
parent af07110f4c
commit 4543381814
25 changed files with 550 additions and 779 deletions
@@ -188,29 +188,6 @@
</div>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">CBX Cache Size</label>
<div class="input-group">
<div class="input-with-unit">
<input
type="text"
pInputText
[(ngModel)]="cbxCacheValue"
placeholder="Cache size"/>
<span class="unit">MB</span>
</div>
<p-button label="Save" severity="success" outlined (onClick)="saveCacheSize()"></p-button>
</div>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Limits the total size (in MB) of the CBX image cache. If exceeded, older cache entries are removed automatically.
</p>
</div>
</div>
</div>
</div>
@@ -47,7 +47,6 @@ export class GlobalPreferencesComponent implements OnInit {
private messageService = inject(MessageService);
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
cbxCacheValue?: number;
maxFileUploadSizeInMb?: number;
ngOnInit(): void {
@@ -55,9 +54,6 @@ export class GlobalPreferencesComponent implements OnInit {
filter(settings => !!settings),
take(1)
).subscribe(settings => {
if (settings?.cbxCacheSizeInMb) {
this.cbxCacheValue = settings.cbxCacheSizeInMb;
}
if (settings?.maxFileUploadSizeInMb) {
this.maxFileUploadSizeInMb = settings.maxFileUploadSizeInMb;
}
@@ -89,15 +85,6 @@ export class GlobalPreferencesComponent implements OnInit {
this.saveSetting(AppSettingKey.COVER_CROPPING_SETTINGS, this.coverCroppingSettings);
}
saveCacheSize(): void {
if (!this.cbxCacheValue || this.cbxCacheValue <= 0) {
this.showMessage('error', 'Invalid Input', 'Please enter a valid cache size in MB.');
return;
}
this.saveSetting(AppSettingKey.CBX_CACHE_SIZE_IN_MB, this.cbxCacheValue);
}
saveFileSize() {
if (!this.maxFileUploadSizeInMb || this.maxFileUploadSizeInMb <= 0) {
this.showMessage('error', 'Invalid Input', 'Please enter a valid max file upload size in MB.');
@@ -448,7 +448,6 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
getTaskIcon(taskType: string): string {
const icons: Record<string, string> = {
[TaskType.CLEAR_CBX_CACHE]: 'pi-database',
[TaskType.CLEAR_PDF_CACHE]: 'pi-database',
[TaskType.REFRESH_LIBRARY_METADATA]: 'pi-refresh',
[TaskType.UPDATE_BOOK_RECOMMENDATIONS]: 'pi-sparkles',
@@ -471,7 +470,6 @@ export class TaskManagementComponent implements OnInit, OnDestroy {
getMetadataIcon(taskType: string): string {
const icons: Record<string, string> = {
[TaskType.CLEAR_CBX_CACHE]: 'pi-database',
[TaskType.CLEAR_PDF_CACHE]: 'pi-database',
[TaskType.CLEANUP_DELETED_BOOKS]: 'pi-trash',
[TaskType.CLEANUP_TEMP_METADATA]: 'pi-file'
@@ -197,7 +197,7 @@ describe('TaskService - API Contract Tests', () => {
describe('Enum value contract', () => {
it('should validate TaskType enum values', () => {
const values = Object.values(TaskType);
expect(values).toContain('CLEAR_CBX_CACHE');
expect(values).toContain('CLEAR_PDF_CACHE');
expect(values).toContain('REFRESH_LIBRARY_METADATA');
expect(values).toContain('REFRESH_METADATA_MANUAL');
});
@@ -228,7 +228,7 @@ describe('TaskService - API Contract Tests', () => {
it('should call correct endpoint for startTask', () => {
httpClientMock.post.mockReturnValue(of({}));
const req: TaskCreateRequest = {taskType: TaskType.CLEAR_CBX_CACHE};
const req: TaskCreateRequest = {taskType: TaskType.CLEAR_PDF_CACHE};
service.startTask(req).subscribe();
expect(httpClientMock.post).toHaveBeenCalledWith(expect.stringMatching(/\/api\/v1\/tasks\/start$/), req);
});
@@ -256,7 +256,7 @@ describe('TaskService - API Contract Tests', () => {
describe('Request payload contract', () => {
it('should send TaskCreateRequest with correct structure', () => {
httpClientMock.post.mockReturnValue(of({}));
const req: TaskCreateRequest = {taskType: TaskType.CLEAR_CBX_CACHE, options: {metadataReplaceMode: MetadataReplaceMode.REPLACE_ALL}};
const req: TaskCreateRequest = {taskType: TaskType.CLEAR_PDF_CACHE, options: {metadataReplaceMode: MetadataReplaceMode.REPLACE_ALL}};
service.startTask(req).subscribe();
expect(httpClientMock.post).toHaveBeenCalledWith(expect.any(String), req);
});
@@ -264,7 +264,7 @@ describe('TaskService - API Contract Tests', () => {
it('should send TaskCronConfigRequest with correct structure', () => {
httpClientMock.patch.mockReturnValue(of({}));
const req: TaskCronConfigRequest = {cronExpression: '0 0 * * *', enabled: false};
service.updateCronConfig(TaskType.CLEAR_CBX_CACHE, req).subscribe();
service.updateCronConfig(TaskType.CLEAR_PDF_CACHE, req).subscribe();
expect(httpClientMock.patch).toHaveBeenCalledWith(expect.any(String), req);
});
});
@@ -272,7 +272,7 @@ describe('TaskService - API Contract Tests', () => {
describe('Response type contract', () => {
it('should expect TaskInfo[] from getAvailableTasks', () => {
const mock: TaskInfo[] = [{
taskType: TaskType.CLEAR_CBX_CACHE,
taskType: TaskType.CLEAR_PDF_CACHE,
name: 'Clear CBX',
description: 'desc',
parallel: false,
@@ -288,9 +288,9 @@ describe('TaskService - API Contract Tests', () => {
});
it('should expect TaskCreateResponse from startTask', () => {
const resp: TaskCreateResponse = {id: '1', type: TaskType.CLEAR_CBX_CACHE, status: TaskStatus.ACCEPTED};
const resp: TaskCreateResponse = {id: '1', type: TaskType.CLEAR_PDF_CACHE, status: TaskStatus.ACCEPTED};
httpClientMock.post.mockReturnValue(of(resp));
service.startTask({taskType: TaskType.CLEAR_CBX_CACHE}).subscribe(result => {
service.startTask({taskType: TaskType.CLEAR_PDF_CACHE}).subscribe(result => {
expect(result).toHaveProperty('id');
expect(result).toHaveProperty('type');
expect(result).toHaveProperty('status');
@@ -319,7 +319,7 @@ describe('TaskService - API Contract Tests', () => {
it('should expect CronConfig from updateCronConfig', () => {
const resp: CronConfig = {
id: 1,
taskType: TaskType.CLEAR_CBX_CACHE,
taskType: TaskType.CLEAR_PDF_CACHE,
cronExpression: '* * * * *',
enabled: true,
options: null,
@@ -327,7 +327,7 @@ describe('TaskService - API Contract Tests', () => {
updatedAt: null
};
httpClientMock.patch.mockReturnValue(of(resp));
service.updateCronConfig(TaskType.CLEAR_CBX_CACHE, {enabled: true}).subscribe(result => {
service.updateCronConfig(TaskType.CLEAR_PDF_CACHE, {enabled: true}).subscribe(result => {
expect(result).toHaveProperty('id');
expect(result).toHaveProperty('taskType');
expect(result).toHaveProperty('enabled');
@@ -5,7 +5,6 @@ import {API_CONFIG} from '../../../core/config/api-config';
import {MetadataRefreshRequest} from '../../metadata/model/request/metadata-refresh-request.model';
export enum TaskType {
CLEAR_CBX_CACHE = 'CLEAR_CBX_CACHE',
CLEAR_PDF_CACHE = 'CLEAR_PDF_CACHE',
REFRESH_LIBRARY_METADATA = 'REFRESH_LIBRARY_METADATA',
UPDATE_BOOK_RECOMMENDATIONS = 'UPDATE_BOOK_RECOMMENDATIONS',
@@ -22,8 +21,7 @@ export const TASK_TYPE_CONFIG: Record<TaskType, { parallel: boolean; async: bool
[TaskType.CLEANUP_DELETED_BOOKS]: {parallel: false, async: false, displayOrder: 4},
[TaskType.CLEANUP_TEMP_METADATA]: {parallel: false, async: false, displayOrder: 5},
[TaskType.REFRESH_METADATA_MANUAL]: {parallel: false, async: false, displayOrder: 6},
[TaskType.CLEAR_CBX_CACHE]: {parallel: false, async: false, displayOrder: 7},
[TaskType.CLEAR_PDF_CACHE]: {parallel: false, async: false, displayOrder: 8},
[TaskType.CLEAR_PDF_CACHE]: {parallel: false, async: false, displayOrder: 7},
};
export enum MetadataReplaceMode {