mirror of
https://github.com/immich-app/immich.git
synced 2025-12-19 01:11:07 +03:00
Compare commits
1 Commits
better-inf
...
deps/immic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bf2f3371d |
@@ -1286,7 +1286,6 @@
|
|||||||
"link_to_oauth": "Link to OAuth",
|
"link_to_oauth": "Link to OAuth",
|
||||||
"linked_oauth_account": "Linked OAuth account",
|
"linked_oauth_account": "Linked OAuth account",
|
||||||
"list": "List",
|
"list": "List",
|
||||||
"live": "Live",
|
|
||||||
"loading": "Loading",
|
"loading": "Loading",
|
||||||
"loading_search_results_failed": "Loading search results failed",
|
"loading_search_results_failed": "Loading search results failed",
|
||||||
"local": "Local",
|
"local": "Local",
|
||||||
@@ -1416,7 +1415,6 @@
|
|||||||
"month": "Month",
|
"month": "Month",
|
||||||
"monthly_title_text_date_format": "MMMM y",
|
"monthly_title_text_date_format": "MMMM y",
|
||||||
"more": "More",
|
"more": "More",
|
||||||
"motion": "Motion",
|
|
||||||
"move": "Move",
|
"move": "Move",
|
||||||
"move_off_locked_folder": "Move out of locked folder",
|
"move_off_locked_folder": "Move out of locked folder",
|
||||||
"move_to": "Move to",
|
"move_to": "Move to",
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_stack.widg
|
|||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/bottom_bar.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/bottom_bar.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/bottom_sheet.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/bottom_sheet.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/motion_photo_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/top_app_bar.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/top_app_bar.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/video_viewer.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/video_viewer.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
@@ -693,7 +692,6 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
backgroundDecoration: BoxDecoration(color: backgroundColor),
|
backgroundDecoration: BoxDecoration(color: backgroundColor),
|
||||||
enablePanAlways: true,
|
enablePanAlways: true,
|
||||||
),
|
),
|
||||||
const Positioned(top: -50, left: 0, right: 0, child: MotionPhotoPlayButton()),
|
|
||||||
if (!showingBottomSheet)
|
if (!showingBottomSheet)
|
||||||
const Positioned(
|
const Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:immich_mobile/extensions/platform_extensions.dart';
|
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
|
||||||
import 'package:immich_mobile/providers/asset_viewer/is_motion_video_playing.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
|
||||||
|
|
||||||
class MotionPhotoPlayButton extends ConsumerWidget {
|
|
||||||
const MotionPhotoPlayButton({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final asset = ref.watch(currentAssetNotifier);
|
|
||||||
final isPlaying = ref.watch(isPlayingMotionVideoProvider);
|
|
||||||
final showControls = ref.watch(assetViewerProvider.select((state) => state.showingControls));
|
|
||||||
final isShowingSheet = ref.watch(assetViewerProvider.select((state) => state.showingBottomSheet));
|
|
||||||
|
|
||||||
if (asset == null || !asset.isMotionPhoto || isShowingSheet) {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
|
|
||||||
return IgnorePointer(
|
|
||||||
ignoring: !showControls,
|
|
||||||
child: AnimatedOpacity(
|
|
||||||
opacity: showControls ? 1.0 : 0.0,
|
|
||||||
duration: Durations.short2,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 60),
|
|
||||||
child: Center(
|
|
||||||
child: _MotionButton(
|
|
||||||
isPlaying: isPlaying,
|
|
||||||
onPressed: ref.read(isPlayingMotionVideoProvider.notifier).toggle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MotionButton extends StatelessWidget {
|
|
||||||
final bool isPlaying;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
const _MotionButton({required this.isPlaying, required this.onPressed});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Material(
|
|
||||||
color: Colors.grey[900]!.withValues(alpha: 0.4),
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(24)),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: onPressed,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(24)),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
isPlaying ? Icons.motion_photos_pause_outlined : Icons.play_circle_outline_rounded,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
CurrentPlatform.isAndroid ? 'motion'.t(context: context) : 'live'.t(context: context),
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
@@ -8,6 +7,7 @@ import 'package:immich_mobile/domain/models/events.model.dart';
|
|||||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/favorite_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/favorite_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/motion_photo_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unfavorite_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unfavorite_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/viewer_kebab_menu.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/viewer_kebab_menu.widget.dart';
|
||||||
@@ -17,7 +17,6 @@ import 'package:immich_mobile/providers/infrastructure/current_album.provider.da
|
|||||||
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
||||||
import 'package:immich_mobile/providers/routes.provider.dart';
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/utils/timezone.dart';
|
|
||||||
|
|
||||||
class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
||||||
const ViewerTopAppBar({super.key});
|
const ViewerTopAppBar({super.key});
|
||||||
@@ -51,6 +50,7 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
final originalTheme = context.themeData;
|
final originalTheme = context.themeData;
|
||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
|
if (asset.isMotionPhoto) const MotionPhotoActionButton(iconOnly: true),
|
||||||
if (album != null && album.isActivityEnabled && album.isShared)
|
if (album != null && album.isActivityEnabled && album.isShared)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.chat_outlined),
|
icon: const Icon(Icons.chat_outlined),
|
||||||
@@ -77,8 +77,6 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
child: AppBar(
|
child: AppBar(
|
||||||
backgroundColor: isShowingSheet ? Colors.transparent : Colors.black.withAlpha(125),
|
backgroundColor: isShowingSheet ? Colors.transparent : Colors.black.withAlpha(125),
|
||||||
leading: const _AppBarBackButton(),
|
leading: const _AppBarBackButton(),
|
||||||
centerTitle: true,
|
|
||||||
title: isShowingSheet ? null : _AssetInfoTitle(asset: asset),
|
|
||||||
iconTheme: const IconThemeData(size: 22, color: Colors.white),
|
iconTheme: const IconThemeData(size: 22, color: Colors.white),
|
||||||
actionsIconTheme: const IconThemeData(size: 22, color: Colors.white),
|
actionsIconTheme: const IconThemeData(size: 22, color: Colors.white),
|
||||||
shape: const Border(),
|
shape: const Border(),
|
||||||
@@ -122,32 +120,3 @@ class _AppBarBackButton extends ConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AssetInfoTitle extends ConsumerWidget {
|
|
||||||
final BaseAsset asset;
|
|
||||||
|
|
||||||
const _AssetInfoTitle({required this.asset});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
DateTime dateTime = asset.createdAt.toLocal();
|
|
||||||
final currentYear = DateTime.now().year;
|
|
||||||
final isCurrentYear = dateTime.year == currentYear;
|
|
||||||
final exifInfo = ref.watch(currentAssetExifProvider).valueOrNull;
|
|
||||||
|
|
||||||
if (exifInfo?.dateTimeOriginal != null) {
|
|
||||||
(dateTime, _) = applyTimezoneOffset(dateTime: exifInfo!.dateTimeOriginal!, timeZone: exifInfo.timeZone);
|
|
||||||
}
|
|
||||||
|
|
||||||
final dateFormatted = isCurrentYear ? DateFormat.MMMd().format(dateTime) : DateFormat.yMMMd().format(dateTime);
|
|
||||||
final timeFormatted = DateFormat.jm().format(dateTime);
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(dateFormatted, style: context.textTheme.labelLarge?.copyWith(color: Colors.white)),
|
|
||||||
Text(timeFormatted, style: context.textTheme.labelMedium?.copyWith(color: Colors.white70)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@@ -717,8 +717,8 @@ importers:
|
|||||||
specifier: file:../open-api/typescript-sdk
|
specifier: file:../open-api/typescript-sdk
|
||||||
version: link:../open-api/typescript-sdk
|
version: link:../open-api/typescript-sdk
|
||||||
'@immich/ui':
|
'@immich/ui':
|
||||||
specifier: ^0.50.1
|
specifier: ^0.51.0
|
||||||
version: 0.50.1(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)
|
version: 0.51.0(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)
|
||||||
'@mapbox/mapbox-gl-rtl-text':
|
'@mapbox/mapbox-gl-rtl-text':
|
||||||
specifier: 0.2.3
|
specifier: 0.2.3
|
||||||
version: 0.2.3(mapbox-gl@1.13.3)
|
version: 0.2.3(mapbox-gl@1.13.3)
|
||||||
@@ -3012,8 +3012,8 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
svelte: ^5.0.0
|
svelte: ^5.0.0
|
||||||
|
|
||||||
'@immich/ui@0.50.1':
|
'@immich/ui@0.51.0':
|
||||||
resolution: {integrity: sha512-fNlQGh75ZFa/UZAgJaYk9/ItHOXHNNzN4CunjCmE7WocVVkUZbUxopN9Ku3F5GULSqD/zJ5gNO6PQAZ1ZoSaaQ==}
|
resolution: {integrity: sha512-suCArLt/h0fPwT1BnpDpycuyx0cZYkuZaW8NOKvzTTAulIT6q67SWCz2Gb+Ae3blKh/b7r5Qoz65v5FzWqZdPQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
svelte: ^5.0.0
|
svelte: ^5.0.0
|
||||||
|
|
||||||
@@ -10424,6 +10424,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-i/w5Ie4tENfGYbdCo2iJ+oies0vOFd8QXWHopKOUzudfLCvnmeheF2PpHp89Z2azpc+c2su3lMiWO/SpP+429A==}
|
resolution: {integrity: sha512-i/w5Ie4tENfGYbdCo2iJ+oies0vOFd8QXWHopKOUzudfLCvnmeheF2PpHp89Z2azpc+c2su3lMiWO/SpP+429A==}
|
||||||
engines: {node: '>=0.12.18'}
|
engines: {node: '>=0.12.18'}
|
||||||
|
|
||||||
|
simple-icons@16.2.0:
|
||||||
|
resolution: {integrity: sha512-SCV4cAX8O2M2WQ3QJm+3k4QdcUIJiBiwKNViQiOwPjWbFWgypzelviW+Bp0A2ij6r/DIEZpTTDcLgD/BE4aexQ==}
|
||||||
|
engines: {node: '>=0.12.18'}
|
||||||
|
|
||||||
sirv@2.0.4:
|
sirv@2.0.4:
|
||||||
resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==}
|
resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==}
|
||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
@@ -14653,14 +14657,14 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
svelte: 5.43.3
|
svelte: 5.43.3
|
||||||
|
|
||||||
'@immich/ui@0.50.1(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)':
|
'@immich/ui@0.51.0(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@immich/svelte-markdown-preprocess': 0.1.0(svelte@5.43.3)
|
'@immich/svelte-markdown-preprocess': 0.1.0(svelte@5.43.3)
|
||||||
'@internationalized/date': 3.10.0
|
'@internationalized/date': 3.10.0
|
||||||
'@mdi/js': 7.4.47
|
'@mdi/js': 7.4.47
|
||||||
bits-ui: 2.14.4(@internationalized/date@3.10.0)(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)
|
bits-ui: 2.14.4(@internationalized/date@3.10.0)(@sveltejs/kit@2.49.2(@opentelemetry/api@1.9.0)(@sveltejs/vite-plugin-svelte@6.2.1(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)(vite@7.3.0(@types/node@24.10.4)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)))(svelte@5.43.3)
|
||||||
luxon: 3.7.2
|
luxon: 3.7.2
|
||||||
simple-icons: 15.22.0
|
simple-icons: 16.2.0
|
||||||
svelte: 5.43.3
|
svelte: 5.43.3
|
||||||
svelte-highlight: 7.9.0
|
svelte-highlight: 7.9.0
|
||||||
tailwind-merge: 3.4.0
|
tailwind-merge: 3.4.0
|
||||||
@@ -23452,6 +23456,8 @@ snapshots:
|
|||||||
|
|
||||||
simple-icons@15.22.0: {}
|
simple-icons@15.22.0: {}
|
||||||
|
|
||||||
|
simple-icons@16.2.0: {}
|
||||||
|
|
||||||
sirv@2.0.4:
|
sirv@2.0.4:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@polka/url': 1.0.0-next.29
|
'@polka/url': 1.0.0-next.29
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ export type Session = {
|
|||||||
isPendingSyncReset: boolean;
|
isPendingSyncReset: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId' | 'lockedProperties'>;
|
export type Exif = Omit<Selectable<AssetExifTable>, 'updatedAt' | 'updateId'>;
|
||||||
|
|
||||||
export type Person = {
|
export type Person = {
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
@@ -465,13 +465,3 @@ export const columns = {
|
|||||||
'plugin.updatedAt as updatedAt',
|
'plugin.updatedAt as updatedAt',
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type LockableProperty = (typeof lockableProperties)[number];
|
|
||||||
export const lockableProperties = [
|
|
||||||
'description',
|
|
||||||
'dateTimeOriginal',
|
|
||||||
'latitude',
|
|
||||||
'longitude',
|
|
||||||
'rating',
|
|
||||||
'timeZone',
|
|
||||||
] as const;
|
|
||||||
|
|||||||
@@ -50,11 +50,9 @@ select
|
|||||||
where
|
where
|
||||||
"asset"."id" = "tag_asset"."assetId"
|
"asset"."id" = "tag_asset"."assetId"
|
||||||
) as agg
|
) as agg
|
||||||
) as "tags",
|
) as "tags"
|
||||||
to_json("asset_exif") as "exifInfo"
|
|
||||||
from
|
from
|
||||||
"asset"
|
"asset"
|
||||||
inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId"
|
|
||||||
where
|
where
|
||||||
"asset"."id" = $2::uuid
|
"asset"."id" = $2::uuid
|
||||||
limit
|
limit
|
||||||
@@ -226,14 +224,6 @@ from
|
|||||||
where
|
where
|
||||||
"asset"."id" = $2
|
"asset"."id" = $2
|
||||||
|
|
||||||
-- AssetJobRepository.getLockedPropertiesForMetadataExtraction
|
|
||||||
select
|
|
||||||
"asset_exif"."lockedProperties"
|
|
||||||
from
|
|
||||||
"asset_exif"
|
|
||||||
where
|
|
||||||
"asset_exif"."assetId" = $1
|
|
||||||
|
|
||||||
-- AssetJobRepository.getAlbumThumbnailFiles
|
-- AssetJobRepository.getAlbumThumbnailFiles
|
||||||
select
|
select
|
||||||
"asset_file"."id",
|
"asset_file"."id",
|
||||||
|
|||||||
@@ -1,49 +1,19 @@
|
|||||||
-- NOTE: This file is auto generated by ./sql-generator
|
-- NOTE: This file is auto generated by ./sql-generator
|
||||||
|
|
||||||
-- AssetRepository.upsertExif
|
|
||||||
insert into
|
|
||||||
"asset_exif" ("dateTimeOriginal", "lockedProperties")
|
|
||||||
values
|
|
||||||
($1, $2)
|
|
||||||
on conflict ("assetId") do update
|
|
||||||
set
|
|
||||||
"dateTimeOriginal" = "excluded"."dateTimeOriginal",
|
|
||||||
"lockedProperties" = nullif(
|
|
||||||
array(
|
|
||||||
select distinct
|
|
||||||
unnest("asset_exif"."lockedProperties" || $3)
|
|
||||||
),
|
|
||||||
'{}'
|
|
||||||
)
|
|
||||||
|
|
||||||
-- AssetRepository.updateAllExif
|
-- AssetRepository.updateAllExif
|
||||||
update "asset_exif"
|
update "asset_exif"
|
||||||
set
|
set
|
||||||
"model" = $1,
|
"model" = $1
|
||||||
"lockedProperties" = nullif(
|
|
||||||
array(
|
|
||||||
select distinct
|
|
||||||
unnest("asset_exif"."lockedProperties" || $2)
|
|
||||||
),
|
|
||||||
'{}'
|
|
||||||
)
|
|
||||||
where
|
where
|
||||||
"assetId" in ($3)
|
"assetId" in ($2)
|
||||||
|
|
||||||
-- AssetRepository.updateDateTimeOriginal
|
-- AssetRepository.updateDateTimeOriginal
|
||||||
update "asset_exif"
|
update "asset_exif"
|
||||||
set
|
set
|
||||||
"dateTimeOriginal" = "dateTimeOriginal" + $1::interval,
|
"dateTimeOriginal" = "dateTimeOriginal" + $1::interval,
|
||||||
"timeZone" = $2,
|
"timeZone" = $2
|
||||||
"lockedProperties" = nullif(
|
|
||||||
array(
|
|
||||||
select distinct
|
|
||||||
unnest("asset_exif"."lockedProperties" || $3)
|
|
||||||
),
|
|
||||||
'{}'
|
|
||||||
)
|
|
||||||
where
|
where
|
||||||
"assetId" in ($4)
|
"assetId" in ($3)
|
||||||
returning
|
returning
|
||||||
"assetId",
|
"assetId",
|
||||||
"dateTimeOriginal",
|
"dateTimeOriginal",
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ export class AssetJobRepository {
|
|||||||
.whereRef('asset.id', '=', 'tag_asset.assetId'),
|
.whereRef('asset.id', '=', 'tag_asset.assetId'),
|
||||||
).as('tags'),
|
).as('tags'),
|
||||||
)
|
)
|
||||||
.$call(withExifInner)
|
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
@@ -129,16 +128,6 @@ export class AssetJobRepository {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [DummyValue.UUID] })
|
|
||||||
async getLockedPropertiesForMetadataExtraction(assetId: string) {
|
|
||||||
return this.db
|
|
||||||
.selectFrom('asset_exif')
|
|
||||||
.select('asset_exif.lockedProperties')
|
|
||||||
.where('asset_exif.assetId', '=', assetId)
|
|
||||||
.executeTakeFirst()
|
|
||||||
.then((row) => row?.lockedProperties ?? []);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GenerateSql({ params: [DummyValue.UUID, AssetFileType.Thumbnail] })
|
@GenerateSql({ params: [DummyValue.UUID, AssetFileType.Thumbnail] })
|
||||||
getAlbumThumbnailFiles(id: string, fileType?: AssetFileType) {
|
getAlbumThumbnailFiles(id: string, fileType?: AssetFileType) {
|
||||||
return this.db
|
return this.db
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ExpressionBuilder, Insertable, Kysely, NotNull, Selectable, sql, Updateable, UpdateResult } from 'kysely';
|
import { Insertable, Kysely, NotNull, Selectable, sql, Updateable, UpdateResult } from 'kysely';
|
||||||
import { isEmpty, isUndefined, omitBy } from 'lodash';
|
import { isEmpty, isUndefined, omitBy } from 'lodash';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { LockableProperty, Stack } from 'src/database';
|
import { Stack } from 'src/database';
|
||||||
import { Chunked, ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
|
import { Chunked, ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { AssetFileType, AssetMetadataKey, AssetOrder, AssetStatus, AssetType, AssetVisibility } from 'src/enum';
|
import { AssetFileType, AssetMetadataKey, AssetOrder, AssetStatus, AssetType, AssetVisibility } from 'src/enum';
|
||||||
@@ -113,77 +113,51 @@ interface GetByIdsRelations {
|
|||||||
tags?: boolean;
|
tags?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const distinctLocked = <T extends LockableProperty[] | null>(eb: ExpressionBuilder<DB, 'asset_exif'>, columns: T) =>
|
|
||||||
sql<T>`nullif(array(select distinct unnest(${eb.ref('asset_exif.lockedProperties')} || ${columns})), '{}')`;
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AssetRepository {
|
export class AssetRepository {
|
||||||
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
||||||
|
|
||||||
@GenerateSql({
|
async upsertExif(exif: Insertable<AssetExifTable>): Promise<void> {
|
||||||
params: [
|
const value = { ...exif, assetId: asUuid(exif.assetId) };
|
||||||
{ dateTimeOriginal: DummyValue.DATE, lockedProperties: ['dateTimeOriginal'] },
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
],
|
|
||||||
})
|
|
||||||
async upsertExif(
|
|
||||||
exif: Insertable<AssetExifTable>,
|
|
||||||
{ lockedPropertiesBehavior }: { lockedPropertiesBehavior: 'override' | 'append' | 'skip' },
|
|
||||||
): Promise<void> {
|
|
||||||
await this.db
|
await this.db
|
||||||
.insertInto('asset_exif')
|
.insertInto('asset_exif')
|
||||||
.values(exif)
|
.values(value)
|
||||||
.onConflict((oc) =>
|
.onConflict((oc) =>
|
||||||
oc.column('assetId').doUpdateSet((eb) => {
|
oc.column('assetId').doUpdateSet((eb) =>
|
||||||
const updateLocked = <T extends keyof AssetExifTable>(col: T) => eb.ref(`excluded.${col}`);
|
removeUndefinedKeys(
|
||||||
const skipLocked = <T extends keyof AssetExifTable>(col: T) =>
|
{
|
||||||
eb
|
description: eb.ref('excluded.description'),
|
||||||
.case()
|
exifImageWidth: eb.ref('excluded.exifImageWidth'),
|
||||||
.when(sql`${col}`, '=', eb.fn.any('asset_exif.lockedProperties'))
|
exifImageHeight: eb.ref('excluded.exifImageHeight'),
|
||||||
.then(eb.ref(`asset_exif.${col}`))
|
fileSizeInByte: eb.ref('excluded.fileSizeInByte'),
|
||||||
.else(eb.ref(`excluded.${col}`))
|
orientation: eb.ref('excluded.orientation'),
|
||||||
.end();
|
dateTimeOriginal: eb.ref('excluded.dateTimeOriginal'),
|
||||||
const ref = lockedPropertiesBehavior === 'skip' ? skipLocked : updateLocked;
|
modifyDate: eb.ref('excluded.modifyDate'),
|
||||||
return {
|
timeZone: eb.ref('excluded.timeZone'),
|
||||||
...removeUndefinedKeys(
|
latitude: eb.ref('excluded.latitude'),
|
||||||
{
|
longitude: eb.ref('excluded.longitude'),
|
||||||
description: ref('description'),
|
projectionType: eb.ref('excluded.projectionType'),
|
||||||
exifImageWidth: ref('exifImageWidth'),
|
city: eb.ref('excluded.city'),
|
||||||
exifImageHeight: ref('exifImageHeight'),
|
livePhotoCID: eb.ref('excluded.livePhotoCID'),
|
||||||
fileSizeInByte: ref('fileSizeInByte'),
|
autoStackId: eb.ref('excluded.autoStackId'),
|
||||||
orientation: ref('orientation'),
|
state: eb.ref('excluded.state'),
|
||||||
dateTimeOriginal: ref('dateTimeOriginal'),
|
country: eb.ref('excluded.country'),
|
||||||
modifyDate: ref('modifyDate'),
|
make: eb.ref('excluded.make'),
|
||||||
timeZone: ref('timeZone'),
|
model: eb.ref('excluded.model'),
|
||||||
latitude: ref('latitude'),
|
lensModel: eb.ref('excluded.lensModel'),
|
||||||
longitude: ref('longitude'),
|
fNumber: eb.ref('excluded.fNumber'),
|
||||||
projectionType: ref('projectionType'),
|
focalLength: eb.ref('excluded.focalLength'),
|
||||||
city: ref('city'),
|
iso: eb.ref('excluded.iso'),
|
||||||
livePhotoCID: ref('livePhotoCID'),
|
exposureTime: eb.ref('excluded.exposureTime'),
|
||||||
autoStackId: ref('autoStackId'),
|
profileDescription: eb.ref('excluded.profileDescription'),
|
||||||
state: ref('state'),
|
colorspace: eb.ref('excluded.colorspace'),
|
||||||
country: ref('country'),
|
bitsPerSample: eb.ref('excluded.bitsPerSample'),
|
||||||
make: ref('make'),
|
rating: eb.ref('excluded.rating'),
|
||||||
model: ref('model'),
|
fps: eb.ref('excluded.fps'),
|
||||||
lensModel: ref('lensModel'),
|
},
|
||||||
fNumber: ref('fNumber'),
|
value,
|
||||||
focalLength: ref('focalLength'),
|
),
|
||||||
iso: ref('iso'),
|
),
|
||||||
exposureTime: ref('exposureTime'),
|
|
||||||
profileDescription: ref('profileDescription'),
|
|
||||||
colorspace: ref('colorspace'),
|
|
||||||
bitsPerSample: ref('bitsPerSample'),
|
|
||||||
rating: ref('rating'),
|
|
||||||
fps: ref('fps'),
|
|
||||||
lockedProperties:
|
|
||||||
lockedPropertiesBehavior === 'append'
|
|
||||||
? distinctLocked(eb, exif.lockedProperties ?? null)
|
|
||||||
: ref('lockedProperties'),
|
|
||||||
},
|
|
||||||
exif,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
@@ -195,26 +169,19 @@ export class AssetRepository {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.db
|
await this.db.updateTable('asset_exif').set(options).where('assetId', 'in', ids).execute();
|
||||||
.updateTable('asset_exif')
|
|
||||||
.set((eb) => ({
|
|
||||||
...options,
|
|
||||||
lockedProperties: distinctLocked(eb, Object.keys(options) as LockableProperty[]),
|
|
||||||
}))
|
|
||||||
.where('assetId', 'in', ids)
|
|
||||||
.execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.NUMBER, DummyValue.STRING] })
|
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.NUMBER, DummyValue.STRING] })
|
||||||
@Chunked()
|
@Chunked()
|
||||||
updateDateTimeOriginal(ids: string[], delta?: number, timeZone?: string) {
|
async updateDateTimeOriginal(
|
||||||
return this.db
|
ids: string[],
|
||||||
|
delta?: number,
|
||||||
|
timeZone?: string,
|
||||||
|
): Promise<{ assetId: string; dateTimeOriginal: Date | null; timeZone: string | null }[]> {
|
||||||
|
return await this.db
|
||||||
.updateTable('asset_exif')
|
.updateTable('asset_exif')
|
||||||
.set((eb) => ({
|
.set({ dateTimeOriginal: sql`"dateTimeOriginal" + ${(delta ?? 0) + ' minute'}::interval`, timeZone })
|
||||||
dateTimeOriginal: sql`"dateTimeOriginal" + ${(delta ?? 0) + ' minute'}::interval`,
|
|
||||||
timeZone,
|
|
||||||
lockedProperties: distinctLocked(eb, ['dateTimeOriginal', 'timeZone']),
|
|
||||||
}))
|
|
||||||
.where('assetId', 'in', ids)
|
.where('assetId', 'in', ids)
|
||||||
.returning(['assetId', 'dateTimeOriginal', 'timeZone'])
|
.returning(['assetId', 'dateTimeOriginal', 'timeZone'])
|
||||||
.execute();
|
.execute();
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Kysely, sql } from 'kysely';
|
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
|
||||||
await sql`ALTER TABLE "asset_exif" ADD "lockedProperties" character varying[];`.execute(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(db: Kysely<any>): Promise<void> {
|
|
||||||
await sql`ALTER TABLE "asset_exif" DROP COLUMN "lockedProperties";`.execute(db);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { LockableProperty } from 'src/database';
|
|
||||||
import { UpdatedAtTrigger, UpdateIdColumn } from 'src/decorators';
|
import { UpdatedAtTrigger, UpdateIdColumn } from 'src/decorators';
|
||||||
import { AssetTable } from 'src/schema/tables/asset.table';
|
import { AssetTable } from 'src/schema/tables/asset.table';
|
||||||
import { Column, ForeignKeyColumn, Generated, Int8, Table, Timestamp, UpdateDateColumn } from 'src/sql-tools';
|
import { Column, ForeignKeyColumn, Generated, Int8, Table, Timestamp, UpdateDateColumn } from 'src/sql-tools';
|
||||||
@@ -98,7 +97,4 @@ export class AssetExifTable {
|
|||||||
|
|
||||||
@UpdateIdColumn({ index: true })
|
@UpdateIdColumn({ index: true })
|
||||||
updateId!: Generated<string>;
|
updateId!: Generated<string>;
|
||||||
|
|
||||||
@Column({ type: 'character varying', array: true, nullable: true })
|
|
||||||
lockedProperties!: Array<LockableProperty> | null;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,10 +370,7 @@ export class AssetMediaService extends BaseService {
|
|||||||
: this.assetRepository.deleteFile({ assetId, type: AssetFileType.Sidecar }));
|
: this.assetRepository.deleteFile({ assetId, type: AssetFileType.Sidecar }));
|
||||||
|
|
||||||
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
await this.assetRepository.upsertExif(
|
await this.assetRepository.upsertExif({ assetId, fileSizeInByte: file.size });
|
||||||
{ assetId, fileSizeInByte: file.size },
|
|
||||||
{ lockedPropertiesBehavior: 'override' },
|
|
||||||
);
|
|
||||||
await this.jobRepository.queue({
|
await this.jobRepository.queue({
|
||||||
name: JobName.AssetExtractMetadata,
|
name: JobName.AssetExtractMetadata,
|
||||||
data: { id: assetId, source: 'upload' },
|
data: { id: assetId, source: 'upload' },
|
||||||
@@ -402,10 +399,7 @@ export class AssetMediaService extends BaseService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { size } = await this.storageRepository.stat(created.originalPath);
|
const { size } = await this.storageRepository.stat(created.originalPath);
|
||||||
await this.assetRepository.upsertExif(
|
await this.assetRepository.upsertExif({ assetId: created.id, fileSizeInByte: size });
|
||||||
{ assetId: created.id, fileSizeInByte: size },
|
|
||||||
{ lockedPropertiesBehavior: 'override' },
|
|
||||||
);
|
|
||||||
await this.jobRepository.queue({ name: JobName.AssetExtractMetadata, data: { id: created.id, source: 'copy' } });
|
await this.jobRepository.queue({ name: JobName.AssetExtractMetadata, data: { id: created.id, source: 'copy' } });
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
@@ -446,10 +440,7 @@ export class AssetMediaService extends BaseService {
|
|||||||
await this.storageRepository.utimes(sidecarFile.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(sidecarFile.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
}
|
}
|
||||||
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
await this.storageRepository.utimes(file.originalPath, new Date(), new Date(dto.fileModifiedAt));
|
||||||
await this.assetRepository.upsertExif(
|
await this.assetRepository.upsertExif({ assetId: asset.id, fileSizeInByte: file.size });
|
||||||
{ assetId: asset.id, fileSizeInByte: file.size },
|
|
||||||
{ lockedPropertiesBehavior: 'override' },
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.eventRepository.emit('AssetCreate', { asset });
|
await this.eventRepository.emit('AssetCreate', { asset });
|
||||||
|
|
||||||
|
|||||||
@@ -225,10 +225,7 @@ describe(AssetService.name, () => {
|
|||||||
|
|
||||||
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
|
await sut.update(authStub.admin, 'asset-1', { description: 'Test description' });
|
||||||
|
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', description: 'Test description' });
|
||||||
{ assetId: 'asset-1', description: 'Test description', lockedProperties: ['description'] },
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the exif rating', async () => {
|
it('should update the exif rating', async () => {
|
||||||
@@ -238,14 +235,7 @@ describe(AssetService.name, () => {
|
|||||||
|
|
||||||
await sut.update(authStub.admin, 'asset-1', { rating: 3 });
|
await sut.update(authStub.admin, 'asset-1', { rating: 3 });
|
||||||
|
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({ assetId: 'asset-1', rating: 3 });
|
||||||
{
|
|
||||||
assetId: 'asset-1',
|
|
||||||
rating: 3,
|
|
||||||
lockedProperties: ['rating'],
|
|
||||||
},
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail linking a live video if the motion part could not be found', async () => {
|
it('should fail linking a live video if the motion part could not be found', async () => {
|
||||||
@@ -437,7 +427,9 @@ describe(AssetService.name, () => {
|
|||||||
});
|
});
|
||||||
expect(mocks.asset.updateAll).toHaveBeenCalled();
|
expect(mocks.asset.updateAll).toHaveBeenCalled();
|
||||||
expect(mocks.asset.updateAllExif).toHaveBeenCalledWith(['asset-1'], { latitude: 0, longitude: 0 });
|
expect(mocks.asset.updateAllExif).toHaveBeenCalledWith(['asset-1'], { latitude: 0, longitude: 0 });
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||||
|
{ name: JobName.SidecarWrite, data: { id: 'asset-1', latitude: 0, longitude: 0 } },
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update exif table if latitude field is provided', async () => {
|
it('should update exif table if latitude field is provided', async () => {
|
||||||
@@ -458,7 +450,9 @@ describe(AssetService.name, () => {
|
|||||||
latitude: 30,
|
latitude: 30,
|
||||||
longitude: 50,
|
longitude: 50,
|
||||||
});
|
});
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||||
|
{ name: JobName.SidecarWrite, data: { id: 'asset-1', dateTimeOriginal, latitude: 30, longitude: 50 } },
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update Assets table if duplicateId is provided as null', async () => {
|
it('should update Assets table if duplicateId is provided as null', async () => {
|
||||||
@@ -488,7 +482,18 @@ describe(AssetService.name, () => {
|
|||||||
timeZone,
|
timeZone,
|
||||||
});
|
});
|
||||||
expect(mocks.asset.updateDateTimeOriginal).toHaveBeenCalledWith(['asset-1'], dateTimeRelative, timeZone);
|
expect(mocks.asset.updateDateTimeOriginal).toHaveBeenCalledWith(['asset-1'], dateTimeRelative, timeZone);
|
||||||
expect(mocks.job.queueAll).toHaveBeenCalledWith([{ name: JobName.SidecarWrite, data: { id: 'asset-1' } }]);
|
expect(mocks.job.queueAll).toHaveBeenCalledWith([
|
||||||
|
{
|
||||||
|
name: JobName.SidecarWrite,
|
||||||
|
data: {
|
||||||
|
id: 'asset-1',
|
||||||
|
dateTimeOriginal: '2020-02-25T06:41:00.000+02:00',
|
||||||
|
description: undefined,
|
||||||
|
latitude: undefined,
|
||||||
|
longitude: undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ import {
|
|||||||
QueueName,
|
QueueName,
|
||||||
} from 'src/enum';
|
} from 'src/enum';
|
||||||
import { BaseService } from 'src/services/base.service';
|
import { BaseService } from 'src/services/base.service';
|
||||||
import { JobItem, JobOf } from 'src/types';
|
import { ISidecarWriteJob, JobItem, JobOf } from 'src/types';
|
||||||
import { requireElevatedPermission } from 'src/utils/access';
|
import { requireElevatedPermission } from 'src/utils/access';
|
||||||
import { getAssetFiles, getMyPartnerIds, onAfterUnlink, onBeforeLink, onBeforeUnlink } from 'src/utils/asset.util';
|
import { getAssetFiles, getMyPartnerIds, onAfterUnlink, onBeforeLink, onBeforeUnlink } from 'src/utils/asset.util';
|
||||||
import { updateLockedColumns } from 'src/utils/database';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AssetService extends BaseService {
|
export class AssetService extends BaseService {
|
||||||
@@ -143,26 +142,56 @@ export class AssetService extends BaseService {
|
|||||||
} = dto;
|
} = dto;
|
||||||
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
await this.requireAccess({ auth, permission: Permission.AssetUpdate, ids });
|
||||||
|
|
||||||
const assetDto = _.omitBy({ isFavorite, visibility, duplicateId }, _.isUndefined);
|
const assetDto = { isFavorite, visibility, duplicateId };
|
||||||
const exifDto = _.omitBy({ latitude, longitude, rating, description, dateTimeOriginal }, _.isUndefined);
|
const exifDto = { latitude, longitude, rating, description, dateTimeOriginal };
|
||||||
|
|
||||||
if (Object.keys(exifDto).length > 0) {
|
const isExifChanged = Object.values(exifDto).some((v) => v !== undefined);
|
||||||
|
if (isExifChanged) {
|
||||||
await this.assetRepository.updateAllExif(ids, exifDto);
|
await this.assetRepository.updateAllExif(ids, exifDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined) {
|
const assets =
|
||||||
await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone);
|
(dateTimeRelative !== undefined && dateTimeRelative !== 0) || timeZone !== undefined
|
||||||
|
? await this.assetRepository.updateDateTimeOriginal(ids, dateTimeRelative, timeZone)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const dateTimesWithTimezone = assets
|
||||||
|
? assets.map((asset) => {
|
||||||
|
const isoString = asset.dateTimeOriginal?.toISOString();
|
||||||
|
let dateTime = isoString ? DateTime.fromISO(isoString) : null;
|
||||||
|
|
||||||
|
if (dateTime && asset.timeZone) {
|
||||||
|
dateTime = dateTime.setZone(asset.timeZone);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
assetId: asset.assetId,
|
||||||
|
dateTimeOriginal: dateTime?.toISO() ?? null,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
: ids.map((id) => ({ assetId: id, dateTimeOriginal }));
|
||||||
|
|
||||||
|
if (dateTimesWithTimezone.length > 0) {
|
||||||
|
await this.jobRepository.queueAll(
|
||||||
|
dateTimesWithTimezone.map(({ assetId: id, dateTimeOriginal }) => ({
|
||||||
|
name: JobName.SidecarWrite,
|
||||||
|
data: {
|
||||||
|
...exifDto,
|
||||||
|
id,
|
||||||
|
dateTimeOriginal: dateTimeOriginal ?? undefined,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(assetDto).length > 0) {
|
const isAssetChanged = Object.values(assetDto).some((v) => v !== undefined);
|
||||||
|
if (isAssetChanged) {
|
||||||
await this.assetRepository.updateAll(ids, assetDto);
|
await this.assetRepository.updateAll(ids, assetDto);
|
||||||
}
|
|
||||||
|
|
||||||
if (visibility === AssetVisibility.Locked) {
|
if (visibility === AssetVisibility.Locked) {
|
||||||
await this.albumRepository.removeAssetsFromAll(ids);
|
await this.albumRepository.removeAssetsFromAll(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.jobRepository.queueAll(ids.map((id) => ({ name: JobName.SidecarWrite, data: { id } })));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async copy(
|
async copy(
|
||||||
@@ -427,25 +456,12 @@ export class AssetService extends BaseService {
|
|||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateExif(dto: {
|
private async updateExif(dto: ISidecarWriteJob) {
|
||||||
id: string;
|
|
||||||
description?: string;
|
|
||||||
dateTimeOriginal?: string;
|
|
||||||
latitude?: number;
|
|
||||||
longitude?: number;
|
|
||||||
rating?: number;
|
|
||||||
}) {
|
|
||||||
const { id, description, dateTimeOriginal, latitude, longitude, rating } = dto;
|
const { id, description, dateTimeOriginal, latitude, longitude, rating } = dto;
|
||||||
const writes = _.omitBy({ description, dateTimeOriginal, latitude, longitude, rating }, _.isUndefined);
|
const writes = _.omitBy({ description, dateTimeOriginal, latitude, longitude, rating }, _.isUndefined);
|
||||||
if (Object.keys(writes).length > 0) {
|
if (Object.keys(writes).length > 0) {
|
||||||
await this.assetRepository.upsertExif(
|
await this.assetRepository.upsertExif({ assetId: id, ...writes });
|
||||||
updateLockedColumns({
|
await this.jobRepository.queue({ name: JobName.SidecarWrite, data: { id, ...writes } });
|
||||||
assetId: id,
|
|
||||||
...writes,
|
|
||||||
}),
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
);
|
|
||||||
await this.jobRepository.queue({ name: JobName.SidecarWrite, data: { id } });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,9 +187,7 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.sidecar.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.sidecar.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: sidecarDate }), {
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: sidecarDate }));
|
||||||
lockedPropertiesBehavior: 'skip',
|
|
||||||
});
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
@@ -216,7 +214,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ dateTimeOriginal: fileModifiedAt }),
|
expect.objectContaining({ dateTimeOriginal: fileModifiedAt }),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
@@ -241,10 +238,7 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ dateTimeOriginal: fileCreatedAt }));
|
||||||
expect.objectContaining({ dateTimeOriginal: fileCreatedAt }),
|
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
@@ -264,7 +258,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
dateTimeOriginal: new Date('2022-01-01T00:00:00.000Z'),
|
dateTimeOriginal: new Date('2022-01-01T00:00:00.000Z'),
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
@@ -288,9 +281,7 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ iso: 160 }), {
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ iso: 160 }));
|
||||||
lockedPropertiesBehavior: 'skip',
|
|
||||||
});
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
duration: null,
|
duration: null,
|
||||||
@@ -319,7 +310,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ city: null, state: null, country: null }),
|
expect.objectContaining({ city: null, state: null, country: null }),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.withLocation.id,
|
id: assetStub.withLocation.id,
|
||||||
@@ -349,7 +339,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ city: 'City', state: 'State', country: 'Country' }),
|
expect.objectContaining({ city: 'City', state: 'State', country: 'Country' }),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith({
|
expect(mocks.asset.update).toHaveBeenCalledWith({
|
||||||
id: assetStub.withLocation.id,
|
id: assetStub.withLocation.id,
|
||||||
@@ -369,10 +358,7 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining({ latitude: null, longitude: null }));
|
||||||
expect.objectContaining({ latitude: null, longitude: null }),
|
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should extract tags from TagsList', async () => {
|
it('should extract tags from TagsList', async () => {
|
||||||
@@ -585,7 +571,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.video.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.video.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({ orientation: ExifOrientation.Rotate270CW.toString() }),
|
expect.objectContaining({ orientation: ExifOrientation.Rotate270CW.toString() }),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -894,40 +879,37 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
expect(mocks.assetJob.getForMetadataExtraction).toHaveBeenCalledWith(assetStub.image.id);
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith({
|
||||||
{
|
assetId: assetStub.image.id,
|
||||||
assetId: assetStub.image.id,
|
bitsPerSample: expect.any(Number),
|
||||||
bitsPerSample: expect.any(Number),
|
autoStackId: null,
|
||||||
autoStackId: null,
|
colorspace: tags.ColorSpace,
|
||||||
colorspace: tags.ColorSpace,
|
dateTimeOriginal: dateForTest,
|
||||||
dateTimeOriginal: dateForTest,
|
description: tags.ImageDescription,
|
||||||
description: tags.ImageDescription,
|
exifImageHeight: null,
|
||||||
exifImageHeight: null,
|
exifImageWidth: null,
|
||||||
exifImageWidth: null,
|
exposureTime: tags.ExposureTime,
|
||||||
exposureTime: tags.ExposureTime,
|
fNumber: null,
|
||||||
fNumber: null,
|
fileSizeInByte: 123_456,
|
||||||
fileSizeInByte: 123_456,
|
focalLength: tags.FocalLength,
|
||||||
focalLength: tags.FocalLength,
|
fps: null,
|
||||||
fps: null,
|
iso: tags.ISO,
|
||||||
iso: tags.ISO,
|
latitude: null,
|
||||||
latitude: null,
|
lensModel: tags.LensModel,
|
||||||
lensModel: tags.LensModel,
|
livePhotoCID: tags.MediaGroupUUID,
|
||||||
livePhotoCID: tags.MediaGroupUUID,
|
longitude: null,
|
||||||
longitude: null,
|
make: tags.Make,
|
||||||
make: tags.Make,
|
model: tags.Model,
|
||||||
model: tags.Model,
|
modifyDate: expect.any(Date),
|
||||||
modifyDate: expect.any(Date),
|
orientation: tags.Orientation?.toString(),
|
||||||
orientation: tags.Orientation?.toString(),
|
profileDescription: tags.ProfileDescription,
|
||||||
profileDescription: tags.ProfileDescription,
|
projectionType: 'EQUIRECTANGULAR',
|
||||||
projectionType: 'EQUIRECTANGULAR',
|
timeZone: tags.tz,
|
||||||
timeZone: tags.tz,
|
rating: tags.Rating,
|
||||||
rating: tags.Rating,
|
country: null,
|
||||||
country: null,
|
state: null,
|
||||||
state: null,
|
city: null,
|
||||||
city: null,
|
});
|
||||||
},
|
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: assetStub.image.id,
|
id: assetStub.image.id,
|
||||||
@@ -961,7 +943,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
timeZone: 'UTC+0',
|
timeZone: 'UTC+0',
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1122,7 +1103,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: '',
|
description: '',
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
mockReadTags({ ImageDescription: ' my\n description' });
|
mockReadTags({ ImageDescription: ' my\n description' });
|
||||||
@@ -1131,7 +1111,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: 'my\n description',
|
description: 'my\n description',
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1144,7 +1123,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
description: '1000',
|
description: '1000',
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1368,7 +1346,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
modifyDate: expect.any(Date),
|
modifyDate: expect.any(Date),
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1381,7 +1358,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: null,
|
rating: null,
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1394,7 +1370,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: 5,
|
rating: 5,
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1407,7 +1382,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rating: -1,
|
rating: -1,
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1529,9 +1503,7 @@ describe(MetadataService.name, () => {
|
|||||||
mockReadTags(exif);
|
mockReadTags(exif);
|
||||||
|
|
||||||
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
await sut.handleMetadataExtraction({ id: assetStub.image.id });
|
||||||
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining(expected), {
|
expect(mocks.asset.upsertExif).toHaveBeenCalledWith(expect.objectContaining(expected));
|
||||||
lockedPropertiesBehavior: 'skip',
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
@@ -1557,7 +1529,6 @@ describe(MetadataService.name, () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
lensModel: expected,
|
lensModel: expected,
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1666,14 +1637,12 @@ describe(MetadataService.name, () => {
|
|||||||
|
|
||||||
describe('handleSidecarWrite', () => {
|
describe('handleSidecarWrite', () => {
|
||||||
it('should skip assets that no longer exist', async () => {
|
it('should skip assets that no longer exist', async () => {
|
||||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(void 0);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(void 0);
|
||||||
await expect(sut.handleSidecarWrite({ id: 'asset-123' })).resolves.toBe(JobStatus.Failed);
|
await expect(sut.handleSidecarWrite({ id: 'asset-123' })).resolves.toBe(JobStatus.Failed);
|
||||||
expect(mocks.metadata.writeTags).not.toHaveBeenCalled();
|
expect(mocks.metadata.writeTags).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip jobs with no metadata', async () => {
|
it('should skip jobs with no metadata', async () => {
|
||||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([]);
|
|
||||||
const asset = factory.jobAssets.sidecarWrite();
|
const asset = factory.jobAssets.sidecarWrite();
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||||
await expect(sut.handleSidecarWrite({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
await expect(sut.handleSidecarWrite({ id: asset.id })).resolves.toBe(JobStatus.Skipped);
|
||||||
@@ -1686,22 +1655,20 @@ describe(MetadataService.name, () => {
|
|||||||
const gps = 12;
|
const gps = 12;
|
||||||
const date = '2023-11-22T04:56:12.196Z';
|
const date = '2023-11-22T04:56:12.196Z';
|
||||||
|
|
||||||
mocks.assetJob.getLockedPropertiesForMetadataExtraction.mockResolvedValue([
|
|
||||||
'description',
|
|
||||||
'latitude',
|
|
||||||
'longitude',
|
|
||||||
'dateTimeOriginal',
|
|
||||||
]);
|
|
||||||
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
mocks.assetJob.getForSidecarWriteJob.mockResolvedValue(asset);
|
||||||
await expect(
|
await expect(
|
||||||
sut.handleSidecarWrite({
|
sut.handleSidecarWrite({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
|
description,
|
||||||
|
latitude: gps,
|
||||||
|
longitude: gps,
|
||||||
|
dateTimeOriginal: date,
|
||||||
}),
|
}),
|
||||||
).resolves.toBe(JobStatus.Success);
|
).resolves.toBe(JobStatus.Success);
|
||||||
expect(mocks.metadata.writeTags).toHaveBeenCalledWith(asset.files[0].path, {
|
expect(mocks.metadata.writeTags).toHaveBeenCalledWith(asset.files[0].path, {
|
||||||
DateTimeOriginal: date,
|
|
||||||
Description: description,
|
Description: description,
|
||||||
ImageDescription: description,
|
ImageDescription: description,
|
||||||
|
DateTimeOriginal: date,
|
||||||
GPSLatitude: gps,
|
GPSLatitude: gps,
|
||||||
GPSLongitude: gps,
|
GPSLongitude: gps,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ export class MetadataService extends BaseService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const promises: Promise<unknown>[] = [
|
const promises: Promise<unknown>[] = [
|
||||||
this.assetRepository.upsertExif(exifData, { lockedPropertiesBehavior: 'skip' }),
|
this.assetRepository.upsertExif(exifData),
|
||||||
this.assetRepository.update({
|
this.assetRepository.update({
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
duration: this.getDuration(exifTags),
|
duration: this.getDuration(exifTags),
|
||||||
@@ -393,34 +393,22 @@ export class MetadataService extends BaseService {
|
|||||||
|
|
||||||
@OnJob({ name: JobName.SidecarWrite, queue: QueueName.Sidecar })
|
@OnJob({ name: JobName.SidecarWrite, queue: QueueName.Sidecar })
|
||||||
async handleSidecarWrite(job: JobOf<JobName.SidecarWrite>): Promise<JobStatus> {
|
async handleSidecarWrite(job: JobOf<JobName.SidecarWrite>): Promise<JobStatus> {
|
||||||
const { id, tags } = job;
|
const { id, description, dateTimeOriginal, latitude, longitude, rating, tags } = job;
|
||||||
const asset = await this.assetJobRepository.getForSidecarWriteJob(id);
|
const asset = await this.assetJobRepository.getForSidecarWriteJob(id);
|
||||||
if (!asset) {
|
if (!asset) {
|
||||||
return JobStatus.Failed;
|
return JobStatus.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lockedProperties = await this.assetJobRepository.getLockedPropertiesForMetadataExtraction(id);
|
|
||||||
const tagsList = (asset.tags || []).map((tag) => tag.value);
|
const tagsList = (asset.tags || []).map((tag) => tag.value);
|
||||||
|
|
||||||
const { sidecarFile } = getAssetFiles(asset.files);
|
const { sidecarFile } = getAssetFiles(asset.files);
|
||||||
const sidecarPath = sidecarFile?.path || `${asset.originalPath}.xmp`;
|
const sidecarPath = sidecarFile?.path || `${asset.originalPath}.xmp`;
|
||||||
|
|
||||||
const { description, dateTimeOriginal, latitude, longitude, rating } = _.pick(
|
|
||||||
{
|
|
||||||
description: asset.exifInfo.description,
|
|
||||||
dateTimeOriginal: asset.exifInfo.dateTimeOriginal,
|
|
||||||
latitude: asset.exifInfo.latitude,
|
|
||||||
longitude: asset.exifInfo.longitude,
|
|
||||||
rating: asset.exifInfo.rating,
|
|
||||||
},
|
|
||||||
lockedProperties,
|
|
||||||
);
|
|
||||||
|
|
||||||
const exif = _.omitBy(
|
const exif = _.omitBy(
|
||||||
<Tags>{
|
<Tags>{
|
||||||
Description: description,
|
Description: description,
|
||||||
ImageDescription: description,
|
ImageDescription: description,
|
||||||
DateTimeOriginal: dateTimeOriginal ? String(dateTimeOriginal) : undefined,
|
DateTimeOriginal: dateTimeOriginal,
|
||||||
GPSLatitude: latitude,
|
GPSLatitude: latitude,
|
||||||
GPSLongitude: longitude,
|
GPSLongitude: longitude,
|
||||||
Rating: rating,
|
Rating: rating,
|
||||||
|
|||||||
@@ -222,6 +222,11 @@ export interface IDeleteFilesJob extends IBaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ISidecarWriteJob extends IEntityJob {
|
export interface ISidecarWriteJob extends IEntityJob {
|
||||||
|
description?: string;
|
||||||
|
dateTimeOriginal?: string;
|
||||||
|
latitude?: number;
|
||||||
|
longitude?: number;
|
||||||
|
rating?: number;
|
||||||
tags?: true;
|
tags?: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { PostgresJSDialect } from 'kysely-postgres-js';
|
|||||||
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
import { parse } from 'pg-connection-string';
|
import { parse } from 'pg-connection-string';
|
||||||
import postgres, { Notice, PostgresError } from 'postgres';
|
import postgres, { Notice, PostgresError } from 'postgres';
|
||||||
import { columns, Exif, lockableProperties, LockableProperty, Person } from 'src/database';
|
import { columns, Exif, Person } from 'src/database';
|
||||||
import { AssetFileType, AssetVisibility, DatabaseExtension, DatabaseSslMode } from 'src/enum';
|
import { AssetFileType, AssetVisibility, DatabaseExtension, DatabaseSslMode } from 'src/enum';
|
||||||
import { AssetSearchBuilderOptions } from 'src/repositories/search.repository';
|
import { AssetSearchBuilderOptions } from 'src/repositories/search.repository';
|
||||||
import { DB } from 'src/schema';
|
import { DB } from 'src/schema';
|
||||||
@@ -488,10 +488,3 @@ export function vectorIndexQuery({ vectorExtension, table, indexName, lists }: V
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateLockedColumns = <T extends Record<string, unknown> & { lockedProperties?: LockableProperty[] }>(
|
|
||||||
exif: T,
|
|
||||||
) => {
|
|
||||||
exif.lockedProperties = lockableProperties.filter((property) => property in exif);
|
|
||||||
return exif;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ export class MediumTestContext<S extends BaseService = BaseService> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async newExif(dto: Insertable<AssetExifTable>) {
|
async newExif(dto: Insertable<AssetExifTable>) {
|
||||||
const result = await this.get(AssetRepository).upsertExif(dto, { lockedPropertiesBehavior: 'override' });
|
const result = await this.get(AssetRepository).upsertExif(dto);
|
||||||
return { result };
|
return { result };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,65 +268,4 @@ describe(AssetService.name, () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('update', () => {
|
|
||||||
it('should update dateTimeOriginal', async () => {
|
|
||||||
const { sut, ctx } = setup();
|
|
||||||
ctx.getMock(JobRepository).queue.mockResolvedValue();
|
|
||||||
const { user } = await ctx.newUser();
|
|
||||||
const auth = factory.auth({ user });
|
|
||||||
const { asset } = await ctx.newAsset({ ownerId: user.id });
|
|
||||||
await ctx.newExif({ assetId: asset.id, description: 'test' });
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
ctx.database
|
|
||||||
.selectFrom('asset_exif')
|
|
||||||
.select('lockedProperties')
|
|
||||||
.where('assetId', '=', asset.id)
|
|
||||||
.executeTakeFirstOrThrow(),
|
|
||||||
).resolves.toEqual({ lockedProperties: null });
|
|
||||||
await sut.update(auth, asset.id, { dateTimeOriginal: '2023-11-19T18:11:00.000-07:00' });
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
ctx.database
|
|
||||||
.selectFrom('asset_exif')
|
|
||||||
.select('lockedProperties')
|
|
||||||
.where('assetId', '=', asset.id)
|
|
||||||
.executeTakeFirstOrThrow(),
|
|
||||||
).resolves.toEqual({ lockedProperties: ['dateTimeOriginal'] });
|
|
||||||
await expect(ctx.get(AssetRepository).getById(asset.id, { exifInfo: true })).resolves.toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
exifInfo: expect.objectContaining({ dateTimeOriginal: '2023-11-20T01:11:00+00:00' }),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('updateAll', () => {
|
|
||||||
it('should relatively update assets', async () => {
|
|
||||||
const { sut, ctx } = setup();
|
|
||||||
ctx.getMock(JobRepository).queueAll.mockResolvedValue();
|
|
||||||
const { user } = await ctx.newUser();
|
|
||||||
const auth = factory.auth({ user });
|
|
||||||
const { asset } = await ctx.newAsset({ ownerId: user.id });
|
|
||||||
await ctx.newExif({ assetId: asset.id, dateTimeOriginal: '2023-11-19T18:11:00' });
|
|
||||||
|
|
||||||
await sut.updateAll(auth, { ids: [asset.id], dateTimeRelative: -11 });
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
ctx.database
|
|
||||||
.selectFrom('asset_exif')
|
|
||||||
.select('lockedProperties')
|
|
||||||
.where('assetId', '=', asset.id)
|
|
||||||
.executeTakeFirstOrThrow(),
|
|
||||||
).resolves.toEqual({ lockedProperties: ['timeZone', 'dateTimeOriginal'] });
|
|
||||||
await expect(ctx.get(AssetRepository).getById(asset.id, { exifInfo: true })).resolves.toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
exifInfo: expect.objectContaining({
|
|
||||||
dateTimeOriginal: '2023-11-19T18:00:00+00:00',
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ describe(MetadataService.name, () => {
|
|||||||
dateTimeOriginal: new Date(expected.dateTimeOriginal),
|
dateTimeOriginal: new Date(expected.dateTimeOriginal),
|
||||||
timeZone: expected.timeZone,
|
timeZone: expected.timeZone,
|
||||||
}),
|
}),
|
||||||
{ lockedPropertiesBehavior: 'skip' },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.asset.update).toHaveBeenCalledWith(
|
expect(mocks.asset.update).toHaveBeenCalledWith(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Kysely } from 'kysely';
|
|||||||
import { AlbumUserRole, SyncEntityType, SyncRequestType } from 'src/enum';
|
import { AlbumUserRole, SyncEntityType, SyncRequestType } from 'src/enum';
|
||||||
import { AssetRepository } from 'src/repositories/asset.repository';
|
import { AssetRepository } from 'src/repositories/asset.repository';
|
||||||
import { DB } from 'src/schema';
|
import { DB } from 'src/schema';
|
||||||
import { updateLockedColumns } from 'src/utils/database';
|
|
||||||
import { SyncTestContext } from 'test/medium.factory';
|
import { SyncTestContext } from 'test/medium.factory';
|
||||||
import { factory } from 'test/small.factory';
|
import { factory } from 'test/small.factory';
|
||||||
import { getKyselyDB, wait } from 'test/utils';
|
import { getKyselyDB, wait } from 'test/utils';
|
||||||
@@ -289,13 +288,10 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
|||||||
|
|
||||||
// update the asset
|
// update the asset
|
||||||
const assetRepository = ctx.get(AssetRepository);
|
const assetRepository = ctx.get(AssetRepository);
|
||||||
await assetRepository.upsertExif(
|
await assetRepository.upsertExif({
|
||||||
updateLockedColumns({
|
assetId: asset.id,
|
||||||
assetId: asset.id,
|
city: 'New City',
|
||||||
city: 'New City',
|
});
|
||||||
}),
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||||
{
|
{
|
||||||
@@ -350,13 +346,10 @@ describe(SyncRequestType.AlbumAssetExifsV1, () => {
|
|||||||
|
|
||||||
// update the asset
|
// update the asset
|
||||||
const assetRepository = ctx.get(AssetRepository);
|
const assetRepository = ctx.get(AssetRepository);
|
||||||
await assetRepository.upsertExif(
|
await assetRepository.upsertExif({
|
||||||
updateLockedColumns({
|
assetId: assetDelayedExif.id,
|
||||||
assetId: assetDelayedExif.id,
|
city: 'Delayed Exif',
|
||||||
city: 'Delayed Exif',
|
});
|
||||||
}),
|
|
||||||
{ lockedPropertiesBehavior: 'append' },
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
await expect(ctx.syncStream(auth, [SyncRequestType.AlbumAssetExifsV1])).resolves.toEqual([
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
AuthApiKey,
|
AuthApiKey,
|
||||||
AuthSharedLink,
|
AuthSharedLink,
|
||||||
AuthUser,
|
AuthUser,
|
||||||
Exif,
|
|
||||||
Library,
|
Library,
|
||||||
Memory,
|
Memory,
|
||||||
Partner,
|
Partner,
|
||||||
@@ -320,28 +319,18 @@ const versionHistoryFactory = () => ({
|
|||||||
version: '1.123.45',
|
version: '1.123.45',
|
||||||
});
|
});
|
||||||
|
|
||||||
const assetSidecarWriteFactory = () => {
|
const assetSidecarWriteFactory = () => ({
|
||||||
const id = newUuid();
|
id: newUuid(),
|
||||||
return {
|
originalPath: '/path/to/original-path.jpg.xmp',
|
||||||
id,
|
tags: [],
|
||||||
originalPath: '/path/to/original-path.jpg.xmp',
|
files: [
|
||||||
tags: [],
|
{
|
||||||
files: [
|
id: newUuid(),
|
||||||
{
|
path: '/path/to/original-path.jpg.xmp',
|
||||||
id: newUuid(),
|
type: AssetFileType.Sidecar,
|
||||||
path: '/path/to/original-path.jpg.xmp',
|
},
|
||||||
type: AssetFileType.Sidecar,
|
],
|
||||||
},
|
});
|
||||||
],
|
|
||||||
exifInfo: {
|
|
||||||
assetId: id,
|
|
||||||
description: 'this is a description',
|
|
||||||
latitude: 12,
|
|
||||||
longitude: 12,
|
|
||||||
dateTimeOriginal: '2023-11-22T04:56:12.196Z',
|
|
||||||
} as unknown as Exif,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const assetOcrFactory = (
|
const assetOcrFactory = (
|
||||||
ocr: {
|
ocr: {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
"@formatjs/icu-messageformat-parser": "^2.9.8",
|
"@formatjs/icu-messageformat-parser": "^2.9.8",
|
||||||
"@immich/justified-layout-wasm": "^0.4.3",
|
"@immich/justified-layout-wasm": "^0.4.3",
|
||||||
"@immich/sdk": "file:../open-api/typescript-sdk",
|
"@immich/sdk": "file:../open-api/typescript-sdk",
|
||||||
"@immich/ui": "^0.50.1",
|
"@immich/ui": "^0.51.0",
|
||||||
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
|
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
|
||||||
"@mdi/js": "^7.4.47",
|
"@mdi/js": "^7.4.47",
|
||||||
"@photo-sphere-viewer/core": "^5.14.0",
|
"@photo-sphere-viewer/core": "^5.14.0",
|
||||||
|
|||||||
@@ -21,7 +21,14 @@
|
|||||||
import { copyToClipboard, getReleaseType, semverToName } from '$lib/utils';
|
import { copyToClipboard, getReleaseType, semverToName } from '$lib/utils';
|
||||||
import { maintenanceShouldRedirect } from '$lib/utils/maintenance';
|
import { maintenanceShouldRedirect } from '$lib/utils/maintenance';
|
||||||
import { isAssetViewerRoute } from '$lib/utils/navigation';
|
import { isAssetViewerRoute } from '$lib/utils/navigation';
|
||||||
import { CommandPaletteContext, modalManager, setTranslations, toastManager, type ActionItem } from '@immich/ui';
|
import {
|
||||||
|
CommandPaletteContext,
|
||||||
|
TooltipProvider,
|
||||||
|
modalManager,
|
||||||
|
setTranslations,
|
||||||
|
toastManager,
|
||||||
|
type ActionItem,
|
||||||
|
} from '@immich/ui';
|
||||||
import { mdiAccountMultipleOutline, mdiBookshelf, mdiCog, mdiServer, mdiSync, mdiThemeLightDark } from '@mdi/js';
|
import { mdiAccountMultipleOutline, mdiBookshelf, mdiCog, mdiServer, mdiSync, mdiThemeLightDark } from '@mdi/js';
|
||||||
import { onMount, type Snippet } from 'svelte';
|
import { onMount, type Snippet } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
@@ -228,15 +235,17 @@
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if page.data.error}
|
<TooltipProvider>
|
||||||
<ErrorLayout error={page.data.error}></ErrorLayout>
|
{#if page.data.error}
|
||||||
{:else}
|
<ErrorLayout error={page.data.error}></ErrorLayout>
|
||||||
{@render children?.()}
|
{:else}
|
||||||
{/if}
|
{@render children?.()}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if showNavigationLoadingBar}
|
{#if showNavigationLoadingBar}
|
||||||
<NavigationLoadingBar />
|
<NavigationLoadingBar />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<DownloadPanel />
|
<DownloadPanel />
|
||||||
<UploadPanel />
|
<UploadPanel />
|
||||||
|
</TooltipProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user