From c40aa4399b21f768617906ca69958317e194a958 Mon Sep 17 00:00:00 2001 From: Alex Phillips Date: Sat, 22 Jul 2023 22:11:00 -0400 Subject: [PATCH] fix(cli): read-only and sidecar support for import (#3372) * added flag to support toggling read-only mode (read-only true by default), added sidecarPath to import request payload * removed default on --no-read-only to prevent confusion since true is the default --- cli/src/commands/upload.ts | 2 ++ cli/src/cores/dto/upload-options-dto.ts | 1 + cli/src/index.ts | 2 ++ 3 files changed, 5 insertions(+) diff --git a/cli/src/commands/upload.ts b/cli/src/commands/upload.ts index fcff0edba..93cb36ec2 100644 --- a/cli/src/commands/upload.ts +++ b/cli/src/commands/upload.ts @@ -70,11 +70,13 @@ export default class Upload extends BaseCommand { if (options.import) { const importData = { assetPath: asset.path, + sidecarPath: asset.sidecarPath, deviceAssetId: asset.deviceAssetId, deviceId: this.deviceId, fileCreatedAt: asset.fileCreatedAt, fileModifiedAt: asset.fileModifiedAt, isFavorite: false, + isReadOnly: options.readOnly, }; if (!this.dryRun) { diff --git a/cli/src/cores/dto/upload-options-dto.ts b/cli/src/cores/dto/upload-options-dto.ts index 41d2cba66..62538cc15 100644 --- a/cli/src/cores/dto/upload-options-dto.ts +++ b/cli/src/cores/dto/upload-options-dto.ts @@ -5,4 +5,5 @@ export class UploadOptionsDto { skipHash = false; delete = false; import = false; + readOnly = true; } diff --git a/cli/src/index.ts b/cli/src/index.ts index 2ef9b56a3..2c48a2c69 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -35,9 +35,11 @@ program .default(false), ) .addOption(new Option('-i, --ignore [paths...]', 'Paths to ignore').env('IMMICH_IGNORE_PATHS').default(false)) + .addOption(new Option('--no-read-only', 'Import files without read-only protection, allowing Immich to manage them')) .argument('[paths...]', 'One or more paths to assets to be uploaded') .action((paths, options) => { options.import = true; + options.excludePatterns = options.ignore; new Upload().run(paths, options); });