1
0
forked from Cutlery/immich
This commit is contained in:
Jonathan Jogenfors 2024-03-16 00:19:31 +01:00
parent 380ae35ca4
commit f7f30a5939
4 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ export enum JobName {
LIBRARY_QUEUE_SCAN_ALL = 'library-queue-all-refresh',
LIBRARY_QUEUE_CLEANUP = 'library-queue-cleanup',
LIBRARY_SCAN_OFFLINE = 'library-scan-offline',
LIBRARY_CHECK_IF_ASSET_ONLINE = 'asset-check-if-online',
LIBRARY_CHECK_OFFLINE = 'library-check-if-online',
LIBRARY_REMOVE_OFFLINE = 'library-remove-offline',
// cleanup
@ -153,7 +153,7 @@ export const JOBS_TO_QUEUE: Record<JobName, QueueName> = {
[JobName.LIBRARY_DELETE]: QueueName.LIBRARY,
[JobName.LIBRARY_SCAN_OFFLINE]: QueueName.LIBRARY,
[JobName.LIBRARY_REMOVE_OFFLINE]: QueueName.LIBRARY,
[JobName.LIBRARY_CHECK_IF_ASSET_ONLINE]: QueueName.LIBRARY,
[JobName.LIBRARY_CHECK_OFFLINE]: QueueName.LIBRARY,
[JobName.LIBRARY_QUEUE_SCAN_ALL]: QueueName.LIBRARY,
[JobName.LIBRARY_QUEUE_CLEANUP]: QueueName.LIBRARY,
};

View File

@ -616,8 +616,8 @@ export class LibraryService extends EventEmitter {
return JobStatus.SUCCESS;
}
async handleQueueOnlineStatusCheck(job: IEntityJob): Promise<JobStatus> {
this.logger.log(`Checking files for online/offline status in library: ${job.id}`);
async handleQueueOfflineCheck(job: IEntityJob): Promise<JobStatus> {
this.logger.log(`Finding offline assets in library: ${job.id}`);
const onlineAssets = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) =>
this.assetRepository.getWith(pagination, WithProperty.IS_ONLINE, job.id),
);
@ -626,7 +626,7 @@ export class LibraryService extends EventEmitter {
this.logger.debug(`Checking if ${assets.length} assets are still online`);
await this.jobRepository.queueAll(
assets.map((asset) => ({
name: JobName.LIBRARY_CHECK_IF_ASSET_ONLINE,
name: JobName.LIBRARY_CHECK_OFFLINE,
data: { id: asset.id },
})),
);
@ -635,8 +635,8 @@ export class LibraryService extends EventEmitter {
return JobStatus.SUCCESS;
}
// Check if an online asset is offline
async handleAssetOnlineCheck(job: IEntityJob): Promise<JobStatus> {
// Check if an asset is has no file, marking it as offline
async handleOfflineCheck(job: IEntityJob): Promise<JobStatus> {
const asset = await this.assetRepository.getById(job.id);
if (!asset || asset.isOffline) {

View File

@ -93,7 +93,7 @@ export type JobItem =
| { name: JobName.LIBRARY_DELETE; data: IEntityJob }
| { name: JobName.LIBRARY_QUEUE_SCAN_ALL; data: IBaseJob }
| { name: JobName.LIBRARY_SCAN_OFFLINE; data: IEntityJob }
| { name: JobName.LIBRARY_CHECK_IF_ASSET_ONLINE; data: IEntityJob }
| { name: JobName.LIBRARY_CHECK_OFFLINE; data: IEntityJob }
| { name: JobName.LIBRARY_QUEUE_CLEANUP; data: IBaseJob };
export enum JobStatus {

View File

@ -77,8 +77,8 @@ export class AppService {
[JobName.LIBRARY_SCAN_ASSET]: (data) => this.libraryService.handleAssetRefresh(data),
[JobName.LIBRARY_SCAN]: (data) => this.libraryService.handleQueueAssetRefresh(data),
[JobName.LIBRARY_DELETE]: (data) => this.libraryService.handleDeleteLibrary(data),
[JobName.LIBRARY_SCAN_OFFLINE]: (data) => this.libraryService.handleQueueOnlineStatusCheck(data),
[JobName.LIBRARY_CHECK_IF_ASSET_ONLINE]: (data) => this.libraryService.handleAssetOnlineCheck(data),
[JobName.LIBRARY_SCAN_OFFLINE]: (data) => this.libraryService.handleQueueOfflineCheck(data),
[JobName.LIBRARY_CHECK_OFFLINE]: (data) => this.libraryService.handleOfflineCheck(data),
[JobName.LIBRARY_REMOVE_OFFLINE]: (data) => this.libraryService.handleOfflineRemoval(data),
[JobName.LIBRARY_QUEUE_SCAN_ALL]: (data) => this.libraryService.handleQueueAllScan(data),
[JobName.LIBRARY_QUEUE_CLEANUP]: () => this.libraryService.handleQueueCleanup(),