From 894107126ec5c9e14ebaa048c5cb56415ed38dd1 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Wed, 20 Mar 2024 00:15:13 +0100 Subject: [PATCH] use library batch size --- e2e/src/api/specs/library.e2e-spec.ts | 2 +- mobile/openapi/README.md | 1 - mobile/openapi/doc/LibraryApi.md | 55 ------------------- mobile/openapi/lib/api/library_api.dart | 40 -------------- mobile/openapi/test/library_api_test.dart | 5 -- open-api/immich-openapi-specs.json | 35 ------------ open-api/typescript-sdk/src/fetch-client.ts | 8 --- server/src/domain/library/library.service.ts | 4 +- .../infra/repositories/asset.repository.ts | 4 +- .../admin/library-management/+page.svelte | 25 --------- 10 files changed, 4 insertions(+), 175 deletions(-) diff --git a/e2e/src/api/specs/library.e2e-spec.ts b/e2e/src/api/specs/library.e2e-spec.ts index b9730aeef..3c4721da4 100644 --- a/e2e/src/api/specs/library.e2e-spec.ts +++ b/e2e/src/api/specs/library.e2e-spec.ts @@ -477,7 +477,7 @@ describe('/library', () => { expect(body).toEqual(errorDto.badRequest('Can only scan external libraries')); }); - it('should scan external library', async () => { + it('should scan an external library', async () => { const library = await utils.createLibrary(admin.accessToken, { ownerId: admin.userId, type: LibraryType.External, diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 3709c9353..d8ff4d30f 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -139,7 +139,6 @@ Class | Method | HTTP request | Description *LibraryApi* | [**getLibrary**](doc//LibraryApi.md#getlibrary) | **GET** /library/{id} | *LibraryApi* | [**getLibraryStatistics**](doc//LibraryApi.md#getlibrarystatistics) | **GET** /library/{id}/statistics | *LibraryApi* | [**removeOfflineFiles**](doc//LibraryApi.md#removeofflinefiles) | **POST** /library/{id}/removeOffline | -*LibraryApi* | [**scanDeletedFiles**](doc//LibraryApi.md#scandeletedfiles) | **POST** /library/{id}/scanDeleted | *LibraryApi* | [**scanLibrary**](doc//LibraryApi.md#scanlibrary) | **POST** /library/{id}/scan | *LibraryApi* | [**updateLibrary**](doc//LibraryApi.md#updatelibrary) | **PUT** /library/{id} | *LibraryApi* | [**validate**](doc//LibraryApi.md#validate) | **POST** /library/{id}/validate | diff --git a/mobile/openapi/doc/LibraryApi.md b/mobile/openapi/doc/LibraryApi.md index acb35c067..8a204788b 100644 --- a/mobile/openapi/doc/LibraryApi.md +++ b/mobile/openapi/doc/LibraryApi.md @@ -15,7 +15,6 @@ Method | HTTP request | Description [**getLibrary**](LibraryApi.md#getlibrary) | **GET** /library/{id} | [**getLibraryStatistics**](LibraryApi.md#getlibrarystatistics) | **GET** /library/{id}/statistics | [**removeOfflineFiles**](LibraryApi.md#removeofflinefiles) | **POST** /library/{id}/removeOffline | -[**scanDeletedFiles**](LibraryApi.md#scandeletedfiles) | **POST** /library/{id}/scanDeleted | [**scanLibrary**](LibraryApi.md#scanlibrary) | **POST** /library/{id}/scan | [**updateLibrary**](LibraryApi.md#updatelibrary) | **PUT** /library/{id} | [**validate**](LibraryApi.md#validate) | **POST** /library/{id}/validate | @@ -349,60 +348,6 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **scanDeletedFiles** -> scanDeletedFiles(id) - - - -### Example -```dart -import 'package:openapi/api.dart'; -// TODO Configure API key authorization: cookie -//defaultApiClient.getAuthentication('cookie').apiKey = 'YOUR_API_KEY'; -// uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//defaultApiClient.getAuthentication('cookie').apiKeyPrefix = 'Bearer'; -// TODO Configure API key authorization: api_key -//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; -// uncomment below to setup prefix (e.g. Bearer) for API key, if needed -//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; -// TODO Configure HTTP Bearer authorization: bearer -// Case 1. Use String Token -//defaultApiClient.getAuthentication('bearer').setAccessToken('YOUR_ACCESS_TOKEN'); -// Case 2. Use Function which generate token. -// String yourTokenGeneratorFunction() { ... } -//defaultApiClient.getAuthentication('bearer').setAccessToken(yourTokenGeneratorFunction); - -final api_instance = LibraryApi(); -final id = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String | - -try { - api_instance.scanDeletedFiles(id); -} catch (e) { - print('Exception when calling LibraryApi->scanDeletedFiles: $e\n'); -} -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **id** | **String**| | - -### Return type - -void (empty response body) - -### Authorization - -[cookie](../README.md#cookie), [api_key](../README.md#api_key), [bearer](../README.md#bearer) - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: Not defined - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **scanLibrary** > scanLibrary(id, scanLibraryDto) diff --git a/mobile/openapi/lib/api/library_api.dart b/mobile/openapi/lib/api/library_api.dart index e8667726b..befd0aeef 100644 --- a/mobile/openapi/lib/api/library_api.dart +++ b/mobile/openapi/lib/api/library_api.dart @@ -293,46 +293,6 @@ class LibraryApi { } } - /// Performs an HTTP 'POST /library/{id}/scanDeleted' operation and returns the [Response]. - /// Parameters: - /// - /// * [String] id (required): - Future scanDeletedFilesWithHttpInfo(String id,) async { - // ignore: prefer_const_declarations - final path = r'/library/{id}/scanDeleted' - .replaceAll('{id}', id); - - // ignore: prefer_final_locals - Object? postBody; - - final queryParams = []; - final headerParams = {}; - final formParams = {}; - - const contentTypes = []; - - - return apiClient.invokeAPI( - path, - 'POST', - queryParams, - postBody, - headerParams, - formParams, - contentTypes.isEmpty ? null : contentTypes.first, - ); - } - - /// Parameters: - /// - /// * [String] id (required): - Future scanDeletedFiles(String id,) async { - final response = await scanDeletedFilesWithHttpInfo(id,); - if (response.statusCode >= HttpStatus.badRequest) { - throw ApiException(response.statusCode, await _decodeBodyBytes(response)); - } - } - /// Performs an HTTP 'POST /library/{id}/scan' operation and returns the [Response]. /// Parameters: /// diff --git a/mobile/openapi/test/library_api_test.dart b/mobile/openapi/test/library_api_test.dart index 4f664fa99..21afeff54 100644 --- a/mobile/openapi/test/library_api_test.dart +++ b/mobile/openapi/test/library_api_test.dart @@ -47,11 +47,6 @@ void main() { // TODO }); - //Future scanDeletedFiles(String id) async - test('test scanDeletedFiles', () async { - // TODO - }); - //Future scanLibrary(String id, ScanLibraryDto scanLibraryDto) async test('test scanLibrary', () async { // TODO diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 986a52068..82562100a 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -3603,41 +3603,6 @@ ] } }, - "/library/{id}/scanDeleted": { - "post": { - "operationId": "scanDeletedFiles", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "format": "uuid", - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "" - } - }, - "security": [ - { - "bearer": [] - }, - { - "cookie": [] - }, - { - "api_key": [] - } - ], - "tags": [ - "Library" - ] - } - }, "/library/{id}/statistics": { "get": { "operationId": "getLibraryStatistics", diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index c7f94c0fa..6b5064252 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -1942,14 +1942,6 @@ export function scanLibrary({ id, scanLibraryDto }: { body: scanLibraryDto }))); } -export function scanDeletedFiles({ id }: { - id: string; -}, opts?: Oazapfts.RequestOpts) { - return oazapfts.ok(oazapfts.fetchText(`/library/${encodeURIComponent(id)}/scanDeleted`, { - ...opts, - method: "POST" - })); -} export function getLibraryStatistics({ id }: { id: string; }, opts?: Oazapfts.RequestOpts) { diff --git a/server/src/domain/library/library.service.ts b/server/src/domain/library/library.service.ts index eb66111ed..1c40f3868 100644 --- a/server/src/domain/library/library.service.ts +++ b/server/src/domain/library/library.service.ts @@ -305,8 +305,6 @@ export class LibraryService extends EventEmitter { }, })), ); - - this.logger.verbose('Asset refresh queued'); } private async validateImportPath(importPath: string): Promise { @@ -639,7 +637,7 @@ export class LibraryService extends EventEmitter { exclusionPatterns: library.exclusionPatterns, }); - const existingAssets = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) => + const existingAssets = usePagination(LIBRARY_SCAN_BATCH_SIZE, (pagination) => this.assetRepository.getWith(pagination, WithProperty.IS_ONLINE, job.id), ); diff --git a/server/src/infra/repositories/asset.repository.ts b/server/src/infra/repositories/asset.repository.ts index c3e913849..86d4e4cc2 100644 --- a/server/src/infra/repositories/asset.repository.ts +++ b/server/src/infra/repositories/asset.repository.ts @@ -476,14 +476,14 @@ export class AssetRepository implements IAssetRepository { if (!libraryId) { throw new Error('Library id is required when finding offline assets'); } - where = [{ isOffline: true, libraryId: libraryId }]; + where = [{ isOffline: true, libraryId }]; break; } case WithProperty.IS_ONLINE: { if (!libraryId) { throw new Error('Library id is required when finding online assets'); } - where = [{ isOffline: false, libraryId: libraryId }]; + where = [{ isOffline: false, libraryId }]; break; } diff --git a/web/src/routes/admin/library-management/+page.svelte b/web/src/routes/admin/library-management/+page.svelte index 55dd071ca..d87a77139 100644 --- a/web/src/routes/admin/library-management/+page.svelte +++ b/web/src/routes/admin/library-management/+page.svelte @@ -31,7 +31,6 @@ type LibraryResponseDto, type LibraryStatsResponseDto, type UserResponseDto, - scanDeletedFiles, } from '@immich/sdk'; import { mdiDatabase, mdiDotsVertical, mdiPlusBoxOutline, mdiSync, mdiUpload } from '@mdi/js'; import { onMount } from 'svelte'; @@ -200,18 +199,6 @@ } }; - const handleScanDeleted = async (libraryId: string) => { - try { - await scanDeletedFiles({ id: libraryId }); - notificationController.show({ - message: `Scanning library for deleted files`, - type: NotificationType.Info, - }); - } catch (error) { - handleError(error, 'Unable to scan library'); - } - }; - const handleScanChanges = async (libraryId: string) => { try { await scanLibrary({ id: libraryId, scanLibraryDto: { refreshModifiedFiles: true } }); @@ -268,14 +255,6 @@ } }; - const onScanDeletedLibraryClicked = async () => { - closeAll(); - - if (selectedLibrary) { - await handleScanDeleted(selectedLibrary.id); - } - }; - const onScanSettingClicked = () => { closeAll(); editScanSettings = selectedLibraryIndex; @@ -425,10 +404,6 @@ onScanSettingClicked()} text="Scan Settings" />
onScanNewLibraryClicked()} text="Scan New Library Files" /> - onScanDeletedLibraryClicked()} - text="Scan Deleted Library Files" - /> onScanAllLibraryFilesClicked()}