mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 17:25:11 +03:00
fix(server): prevent feedback loop during library scan (#7944)
* prevent feedback loop * add nesting * made nesting less ugly --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
userStub,
|
||||
} from '@test';
|
||||
import { when } from 'jest-when';
|
||||
import { R_OK } from 'node:constants';
|
||||
import { Stats } from 'node:fs';
|
||||
import { ILibraryFileJob, ILibraryRefreshJob, JobName } from '../job';
|
||||
import {
|
||||
@@ -1632,5 +1633,32 @@ describe(LibraryService.name, () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should detect when import path is in immich media folder', async () => {
|
||||
storageMock.stat.mockResolvedValue({ isDirectory: () => true } as Stats);
|
||||
const validImport = libraryStub.hasImmichPaths.importPaths[1];
|
||||
when(storageMock.checkFileExists).calledWith(validImport, R_OK).mockResolvedValue(true);
|
||||
|
||||
const result = await sut.validate(authStub.external1, libraryStub.hasImmichPaths.id, {
|
||||
importPaths: libraryStub.hasImmichPaths.importPaths,
|
||||
});
|
||||
|
||||
expect(result.importPaths).toEqual([
|
||||
{
|
||||
importPath: libraryStub.hasImmichPaths.importPaths[0],
|
||||
isValid: false,
|
||||
message: 'Cannot use media upload folder for external libraries',
|
||||
},
|
||||
{
|
||||
importPath: validImport,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
importPath: libraryStub.hasImmichPaths.importPaths[2],
|
||||
isValid: false,
|
||||
message: 'Cannot use media upload folder for external libraries',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user