mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 09:15:44 +03:00
feat: initialise StorageCore in maintenance mode
This commit is contained in:
@@ -8,6 +8,7 @@ import { OpenTelemetryModule } from 'nestjs-otel';
|
|||||||
import { commandsAndQuestions } from 'src/commands';
|
import { commandsAndQuestions } from 'src/commands';
|
||||||
import { IWorker } from 'src/constants';
|
import { IWorker } from 'src/constants';
|
||||||
import { controllers } from 'src/controllers';
|
import { controllers } from 'src/controllers';
|
||||||
|
import { StorageCore } from 'src/cores/storage.core';
|
||||||
import { ImmichWorker } from 'src/enum';
|
import { ImmichWorker } from 'src/enum';
|
||||||
import { MaintenanceAuthGuard } from 'src/maintenance/maintenance-auth.guard';
|
import { MaintenanceAuthGuard } from 'src/maintenance/maintenance-auth.guard';
|
||||||
import { MaintenanceWebsocketRepository } from 'src/maintenance/maintenance-websocket.repository';
|
import { MaintenanceWebsocketRepository } from 'src/maintenance/maintenance-websocket.repository';
|
||||||
@@ -128,6 +129,8 @@ export class MaintenanceModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
|
StorageCore.setMediaLocation(this.maintenanceWorkerService.detectMediaLocation());
|
||||||
|
|
||||||
await this.maintenanceWorkerService.logSecret();
|
await this.maintenanceWorkerService.logSecret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,32 @@ export class MaintenanceWorkerService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link _StorageService.detectMediaLocation}
|
||||||
|
*/
|
||||||
|
detectMediaLocation(): string {
|
||||||
|
const envData = this.configRepository.getEnv();
|
||||||
|
if (envData.storage.mediaLocation) {
|
||||||
|
return envData.storage.mediaLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targets: string[] = [];
|
||||||
|
const candidates = ['/data', '/usr/src/app/upload'];
|
||||||
|
|
||||||
|
for (const candidate of candidates) {
|
||||||
|
const exists = this.storageRepository.existsSync(candidate);
|
||||||
|
if (exists) {
|
||||||
|
targets.push(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targets.length === 1) {
|
||||||
|
return targets[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '/usr/src/app/upload';
|
||||||
|
}
|
||||||
|
|
||||||
private async secret(): Promise<string> {
|
private async secret(): Promise<string> {
|
||||||
const state = (await this.systemMetadataRepository.get(SystemMetadataKey.MaintenanceMode)) as {
|
const state = (await this.systemMetadataRepository.get(SystemMetadataKey.MaintenanceMode)) as {
|
||||||
secret: string;
|
secret: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user