mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(server): improve library scan queuing performance (#4418)
* fix: inline mark asset as offline * fix: improve log message * chore: lint * fix: offline asset algorithm * fix: use set comparison to check what to import * fix: only mark new offline files as offline * fix: compare the correct array * fix: set default library concurrency to 5 * fix: remove one db call when scanning new files * chore: remove unused import --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
parent
99e9c2ada6
commit
56eb7bf0fc
10 changed files with 25 additions and 77 deletions
|
|
@ -16,7 +16,7 @@ import {
|
|||
userStub,
|
||||
} from '@test';
|
||||
import { Stats } from 'fs';
|
||||
import { ILibraryFileJob, ILibraryRefreshJob, IOfflineLibraryFileJob, JobName } from '../job';
|
||||
import { ILibraryFileJob, ILibraryRefreshJob, JobName } from '../job';
|
||||
import {
|
||||
IAssetRepository,
|
||||
ICryptoRepository,
|
||||
|
|
@ -126,14 +126,11 @@ describe(LibraryService.name, () => {
|
|||
|
||||
await sut.handleQueueAssetRefresh(mockLibraryJob);
|
||||
|
||||
expect(jobMock.queue.mock.calls).toEqual([
|
||||
expect(assetMock.updateAll.mock.calls).toEqual([
|
||||
[
|
||||
[assetStub.external.id],
|
||||
{
|
||||
name: JobName.LIBRARY_MARK_ASSET_OFFLINE,
|
||||
data: {
|
||||
id: libraryStub.externalLibrary1.id,
|
||||
assetPath: '/data/user1/photo.jpg',
|
||||
},
|
||||
isOffline: true,
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
|
@ -150,7 +147,7 @@ describe(LibraryService.name, () => {
|
|||
|
||||
userMock.get.mockResolvedValue(userStub.user1);
|
||||
|
||||
expect(sut.handleQueueAssetRefresh(mockLibraryJob)).resolves.toBe(false);
|
||||
await expect(sut.handleQueueAssetRefresh(mockLibraryJob)).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('should not scan upload libraries', async () => {
|
||||
|
|
@ -162,7 +159,7 @@ describe(LibraryService.name, () => {
|
|||
|
||||
libraryMock.get.mockResolvedValue(libraryStub.uploadLibrary1);
|
||||
|
||||
expect(sut.handleQueueAssetRefresh(mockLibraryJob)).resolves.toBe(false);
|
||||
await expect(sut.handleQueueAssetRefresh(mockLibraryJob)).resolves.toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -545,24 +542,6 @@ describe(LibraryService.name, () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('handleOfflineAsset', () => {
|
||||
it('should mark an asset as offline', async () => {
|
||||
const offlineJob: IOfflineLibraryFileJob = {
|
||||
id: libraryStub.externalLibrary1.id,
|
||||
assetPath: '/data/user1/photo.jpg',
|
||||
};
|
||||
|
||||
assetMock.getByLibraryIdAndOriginalPath.mockResolvedValue(assetStub.image);
|
||||
|
||||
await expect(sut.handleOfflineAsset(offlineJob)).resolves.toBe(true);
|
||||
|
||||
expect(assetMock.save).toHaveBeenCalledWith({
|
||||
id: assetStub.image.id,
|
||||
isOffline: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
it('should delete a library', async () => {
|
||||
assetMock.getByLibraryIdAndOriginalPath.mockResolvedValue(assetStub.image);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue