From e4f32a045d8003f9d588cf110cd9a02d5b68a874 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Wed, 28 Feb 2024 21:20:10 +0100 Subject: [PATCH] chore: remove watcher polling option (#7480) * remove watcher polling * fix lint * add db migration --- docs/docs/features/libraries.md | 5 +--- .../doc/SystemConfigLibraryWatchDto.md | Bin 483 -> 422 bytes .../system_config_library_watch_dto.dart | Bin 3503 -> 2995 bytes .../system_config_library_watch_dto_test.dart | Bin 802 -> 601 bytes open-api/immich-openapi-specs.json | 10 +------- open-api/typescript-sdk/axios-client/api.ts | 12 ---------- open-api/typescript-sdk/fetch-client.ts | Bin 74942 -> 74895 bytes server/src/domain/library/library.service.ts | 9 +------ .../dto/system-config-library.dto.ts | 11 --------- .../system-config/system-config.core.ts | 2 -- .../system-config.service.spec.ts | 2 -- .../infra/entities/system-config.entity.ts | 4 ---- ...0004123-RemoveLibraryWatchPollingOption.ts | 12 ++++++++++ .../library-settings/library-settings.svelte | 22 ------------------ 14 files changed, 15 insertions(+), 74 deletions(-) create mode 100644 server/src/infra/migrations/1709150004123-RemoveLibraryWatchPollingOption.ts diff --git a/docs/docs/features/libraries.md b/docs/docs/features/libraries.md index 995d652492..58dd707ea0 100644 --- a/docs/docs/features/libraries.md +++ b/docs/docs/features/libraries.md @@ -88,10 +88,7 @@ Some basic examples: This feature - currently hidden in the config file - is considered experimental and for advanced users only. If enabled, it will allow automatic watching of the filesystem which means new assets are automatically imported to Immich without needing to rescan. Deleted assets are, as always, marked as offline and can be removed with the "Remove offline files" button. -If your photos are on a network drive you will likely have to enable filesystem polling. The performance hit for polling large libraries is currently unknown, feel free to test this feature and report back. In addition to the boolean feature flag, the configuration file allows customization of the following parameters, please see the [chokidar documentation](https://github.com/paulmillr/chokidar?tab=readme-ov-file#performance) for reference. - -- `usePolling` (default: `false`). -- `interval`. (default: 10000). When using polling, this is how often (in milliseconds) the filesystem is polled. +If your photos are on a network drive, automatic file watching likely won't work. In that case, you will have to rely on a periodic library refresh to pull in your changes. ### Nightly job diff --git a/mobile/openapi/doc/SystemConfigLibraryWatchDto.md b/mobile/openapi/doc/SystemConfigLibraryWatchDto.md index baa0be6b084d13f93384b5043e4a3007f64a1d38..43b975e21abe7b79539424b99f24d2676cfdae50 100644 GIT binary patch delta 11 ScmaFNyo`ARBjaQ{#-#ulU<0`T delta 52 zcmZ3+{Fr$IBcrC4R%TvFYEfBYj+T}}jRKepW&t@|T3V&WsR8*pIhlFs6W{Ix0H*>G ARsaA1 diff --git a/mobile/openapi/lib/model/system_config_library_watch_dto.dart b/mobile/openapi/lib/model/system_config_library_watch_dto.dart index 795fd15fd33b9d79a5fd7fb00bf133ddad563d9b..0bcb6f1771d7bc824f2e98cea2d11b150de168c0 100644 GIT binary patch delta 60 zcmZ24y;*$2K1ShMO=~VL1%;&i{2YbUyu_rO)Rf5vOcN(_GAB)5$Q(Rbfu&;eJC;L? Qo3+_v*w|{VxoWw%0A4i``v3p{ delta 497 zcmdlizFvC6K1MSIg`(8L(#)dN6orzE%woOFypq(Svcw!6E(IV!l`Aby4am>Q$;?Zi zyo*sr0jLy&!OE?t|nf;QMJ4VbNZ8HvRi&iN^+nlKq84ZE0Pb#&mi*s8!Z=^&YEtAeCKoVg-EK_RO+ zKQFpS9j016R>2lEWURq%fGb28fKZAM+uX@~g3(<8?hGr1+{A*g#GKMp|Fn?Gf>axz zJ$4!(J9QM0EY(zmgg+<_5Qa@wV3p@Wa5uZLrn6}%C?MPl(WH)0q7D+NwdShj;sOAS CEv0Ax diff --git a/mobile/openapi/test/system_config_library_watch_dto_test.dart b/mobile/openapi/test/system_config_library_watch_dto_test.dart index 74ab53d652bedd1ea642f27aa0a1c869d6550504..19b5de05fe24d037e014c6a6d81cd4cfba1826a2 100644 GIT binary patch delta 18 ZcmZ3)c9Ug;KNA<1fqOhZ;iw diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 44772e14a2..9f6b0ce607 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -9831,18 +9831,10 @@ "properties": { "enabled": { "type": "boolean" - }, - "interval": { - "type": "integer" - }, - "usePolling": { - "type": "boolean" } }, "required": [ - "enabled", - "interval", - "usePolling" + "enabled" ], "type": "object" }, diff --git a/open-api/typescript-sdk/axios-client/api.ts b/open-api/typescript-sdk/axios-client/api.ts index 154fc99693..0da04a8f2a 100644 --- a/open-api/typescript-sdk/axios-client/api.ts +++ b/open-api/typescript-sdk/axios-client/api.ts @@ -4401,18 +4401,6 @@ export interface SystemConfigLibraryWatchDto { * @memberof SystemConfigLibraryWatchDto */ 'enabled': boolean; - /** - * - * @type {number} - * @memberof SystemConfigLibraryWatchDto - */ - 'interval': number; - /** - * - * @type {boolean} - * @memberof SystemConfigLibraryWatchDto - */ - 'usePolling': boolean; } /** * diff --git a/open-api/typescript-sdk/fetch-client.ts b/open-api/typescript-sdk/fetch-client.ts index 5e97521274e4471f8ff619553291e7dfc6c2f094..fb0d04d2bb63b382599501fa40f56c8659da72d3 100644 GIT binary patch delta 22 ecmdmYlBNG7%Z6G0llg$d6fS|NEH6TAHCo?a7alijn E0Q=Sxj{pDw diff --git a/server/src/domain/library/library.service.ts b/server/src/domain/library/library.service.ts index 7c961963ec..6a5982abef 100644 --- a/server/src/domain/library/library.service.ts +++ b/server/src/domain/library/library.service.ts @@ -112,20 +112,13 @@ export class LibraryService extends EventEmitter { ignore: library.exclusionPatterns, }); - const config = await this.configCore.getConfig(); - const { usePolling, interval } = config.library.watch; - - this.logger.debug(`Settings for watcher: usePolling: ${usePolling}, interval: ${interval}`); - let _resolve: () => void; const ready$ = new Promise((resolve) => (_resolve = resolve)); this.watchers[id] = this.storageRepository.watch( library.importPaths, { - usePolling, - interval, - binaryInterval: interval, + usePolling: false, ignoreInitial: true, }, { diff --git a/server/src/domain/system-config/dto/system-config-library.dto.ts b/server/src/domain/system-config/dto/system-config-library.dto.ts index caf73498f2..fdbae600f6 100644 --- a/server/src/domain/system-config/dto/system-config-library.dto.ts +++ b/server/src/domain/system-config/dto/system-config-library.dto.ts @@ -1,12 +1,9 @@ import { validateCronExpression } from '@app/domain'; -import { ApiProperty } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsBoolean, - IsInt, IsNotEmpty, IsObject, - IsPositive, IsString, Validate, ValidateIf, @@ -38,14 +35,6 @@ export class SystemConfigLibraryScanDto { export class SystemConfigLibraryWatchDto { @IsBoolean() enabled!: boolean; - - @IsBoolean() - usePolling!: boolean; - - @IsInt() - @IsPositive() - @ApiProperty({ type: 'integer' }) - interval!: number; } export class SystemConfigLibraryDto { diff --git a/server/src/domain/system-config/system-config.core.ts b/server/src/domain/system-config/system-config.core.ts index eb661133b2..d32309955d 100644 --- a/server/src/domain/system-config/system-config.core.ts +++ b/server/src/domain/system-config/system-config.core.ts @@ -132,8 +132,6 @@ export const defaults = Object.freeze({ }, watch: { enabled: false, - usePolling: false, - interval: 10_000, }, }, server: { diff --git a/server/src/domain/system-config/system-config.service.spec.ts b/server/src/domain/system-config/system-config.service.spec.ts index ec0b4b8f4f..67a6418f44 100644 --- a/server/src/domain/system-config/system-config.service.spec.ts +++ b/server/src/domain/system-config/system-config.service.spec.ts @@ -136,8 +136,6 @@ const updatedConfig = Object.freeze({ }, watch: { enabled: false, - usePolling: false, - interval: 10_000, }, }, }); diff --git a/server/src/infra/entities/system-config.entity.ts b/server/src/infra/entities/system-config.entity.ts index 8307a0328e..edf4734359 100644 --- a/server/src/infra/entities/system-config.entity.ts +++ b/server/src/infra/entities/system-config.entity.ts @@ -51,8 +51,6 @@ export enum SystemConfigKey { LIBRARY_SCAN_CRON_EXPRESSION = 'library.scan.cronExpression', LIBRARY_WATCH_ENABLED = 'library.watch.enabled', - LIBRARY_WATCH_USE_POLLING = 'library.watch.usePolling', - LIBRARY_WATCH_INTERVAL = 'library.watch.interval', LOGGING_ENABLED = 'logging.enabled', LOGGING_LEVEL = 'logging.level', @@ -268,8 +266,6 @@ export interface SystemConfig { }; watch: { enabled: boolean; - usePolling: boolean; - interval: number; }; }; server: { diff --git a/server/src/infra/migrations/1709150004123-RemoveLibraryWatchPollingOption.ts b/server/src/infra/migrations/1709150004123-RemoveLibraryWatchPollingOption.ts new file mode 100644 index 0000000000..8b7ff3a675 --- /dev/null +++ b/server/src/infra/migrations/1709150004123-RemoveLibraryWatchPollingOption.ts @@ -0,0 +1,12 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class RemoveLibraryWatchPollingOption1709150004123 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DELETE FROM "system_config" WHERE key = 'library.watch.usePolling'`); + await queryRunner.query(`DELETE FROM "system_config" WHERE key = 'library.watch.interval'`); + } + + public async down(): Promise { + // noop + } +} diff --git a/web/src/lib/components/admin-page/settings/library-settings/library-settings.svelte b/web/src/lib/components/admin-page/settings/library-settings/library-settings.svelte index 746db2c198..c1076abc54 100644 --- a/web/src/lib/components/admin-page/settings/library-settings/library-settings.svelte +++ b/web/src/lib/components/admin-page/settings/library-settings/library-settings.svelte @@ -42,28 +42,6 @@ subtitle="Watch external libraries for file changes" bind:checked={config.library.watch.enabled} /> - - - - - -

- Interval of filesystem polling, in milliseconds. Lower values will result in higher CPU usage. -

-
-