mirror of
https://github.com/immich-app/immich.git
synced 2025-01-04 02:46:47 +01:00
fix(server): library folder missing on new install (#2597)
This commit is contained in:
parent
ffe397247e
commit
caba462703
3 changed files with 17 additions and 0 deletions
|
@ -6,6 +6,7 @@ import {
|
||||||
MACHINE_LEARNING_ENABLED,
|
MACHINE_LEARNING_ENABLED,
|
||||||
SearchService,
|
SearchService,
|
||||||
SERVER_VERSION,
|
SERVER_VERSION,
|
||||||
|
StorageService,
|
||||||
} from '@app/domain';
|
} from '@app/domain';
|
||||||
import { RedisIoAdapter } from '@app/infra';
|
import { RedisIoAdapter } from '@app/infra';
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
|
@ -72,6 +73,8 @@ async function bootstrap() {
|
||||||
customSiteTitle: 'Immich API Documentation',
|
customSiteTitle: 'Immich API Documentation',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get(StorageService).init();
|
||||||
|
|
||||||
await app.listen(serverPort, () => {
|
await app.listen(serverPort, () => {
|
||||||
if (process.env.NODE_ENV == 'development') {
|
if (process.env.NODE_ENV == 'development') {
|
||||||
// Generate API Documentation only in development mode
|
// Generate API Documentation only in development mode
|
||||||
|
|
|
@ -15,6 +15,13 @@ describe(StorageService.name, () => {
|
||||||
expect(sut).toBeDefined();
|
expect(sut).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('init', () => {
|
||||||
|
it('should create the library folder on initialization', () => {
|
||||||
|
sut.init();
|
||||||
|
expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/library');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('handleDeleteFiles', () => {
|
describe('handleDeleteFiles', () => {
|
||||||
it('should handle null values', async () => {
|
it('should handle null values', async () => {
|
||||||
await sut.handleDeleteFiles({ files: [undefined, null] });
|
await sut.handleDeleteFiles({ files: [undefined, null] });
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
import { Inject, Injectable, Logger } from '@nestjs/common';
|
import { Inject, Injectable, Logger } from '@nestjs/common';
|
||||||
import { IDeleteFilesJob } from '../job';
|
import { IDeleteFilesJob } from '../job';
|
||||||
|
import { StorageCore, StorageFolder } from './storage.core';
|
||||||
import { IStorageRepository } from './storage.repository';
|
import { IStorageRepository } from './storage.repository';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StorageService {
|
export class StorageService {
|
||||||
private logger = new Logger(StorageService.name);
|
private logger = new Logger(StorageService.name);
|
||||||
|
private storageCore = new StorageCore();
|
||||||
|
|
||||||
constructor(@Inject(IStorageRepository) private storageRepository: IStorageRepository) {}
|
constructor(@Inject(IStorageRepository) private storageRepository: IStorageRepository) {}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
const libraryBase = this.storageCore.getBaseFolder(StorageFolder.LIBRARY);
|
||||||
|
this.storageRepository.mkdirSync(libraryBase);
|
||||||
|
}
|
||||||
|
|
||||||
async handleDeleteFiles(job: IDeleteFilesJob) {
|
async handleDeleteFiles(job: IDeleteFilesJob) {
|
||||||
const { files } = job;
|
const { files } = job;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue