mirror of
https://github.com/immich-app/immich.git
synced 2026-02-04 08:49:01 +03:00
fix: don't include metadata when upload motion part of LivePhotos (#25400)
* fix: don't include metadata when upload motion part of LivePhotos * fix: get original file name
This commit is contained in:
@@ -307,10 +307,10 @@ class BackgroundUploadService {
|
|||||||
priority: priority,
|
priority: priority,
|
||||||
isFavorite: asset.isFavorite,
|
isFavorite: asset.isFavorite,
|
||||||
requiresWiFi: requiresWiFi,
|
requiresWiFi: requiresWiFi,
|
||||||
cloudId: asset.cloudId,
|
cloudId: entity.isLivePhoto ? null : asset.cloudId,
|
||||||
adjustmentTime: asset.adjustmentTime?.toIso8601String(),
|
adjustmentTime: entity.isLivePhoto ? null : asset.adjustmentTime?.toIso8601String(),
|
||||||
latitude: asset.latitude?.toString(),
|
latitude: entity.isLivePhoto ? null : asset.latitude?.toString(),
|
||||||
longitude: asset.longitude?.toString(),
|
longitude: entity.isLivePhoto ? null : asset.longitude?.toString(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import 'package:immich_mobile/platform/connectivity_api.g.dart';
|
|||||||
import 'package:immich_mobile/providers/app_settings.provider.dart';
|
import 'package:immich_mobile/providers/app_settings.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/storage.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/storage.provider.dart';
|
||||||
|
import 'package:immich_mobile/repositories/asset_media.repository.dart';
|
||||||
import 'package:immich_mobile/repositories/upload.repository.dart';
|
import 'package:immich_mobile/repositories/upload.repository.dart';
|
||||||
import 'package:immich_mobile/services/api.service.dart';
|
import 'package:immich_mobile/services/api.service.dart';
|
||||||
import 'package:immich_mobile/services/app_settings.service.dart';
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
||||||
@@ -40,6 +41,7 @@ final foregroundUploadServiceProvider = Provider((ref) {
|
|||||||
ref.watch(backupRepositoryProvider),
|
ref.watch(backupRepositoryProvider),
|
||||||
ref.watch(connectivityApiProvider),
|
ref.watch(connectivityApiProvider),
|
||||||
ref.watch(appSettingsServiceProvider),
|
ref.watch(appSettingsServiceProvider),
|
||||||
|
ref.watch(assetMediaRepositoryProvider),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -55,6 +57,7 @@ class ForegroundUploadService {
|
|||||||
this._backupRepository,
|
this._backupRepository,
|
||||||
this._connectivityApi,
|
this._connectivityApi,
|
||||||
this._appSettingsService,
|
this._appSettingsService,
|
||||||
|
this._assetMediaRepository,
|
||||||
);
|
);
|
||||||
|
|
||||||
final UploadRepository _uploadRepository;
|
final UploadRepository _uploadRepository;
|
||||||
@@ -62,6 +65,7 @@ class ForegroundUploadService {
|
|||||||
final DriftBackupRepository _backupRepository;
|
final DriftBackupRepository _backupRepository;
|
||||||
final ConnectivityApi _connectivityApi;
|
final ConnectivityApi _connectivityApi;
|
||||||
final AppSettingsService _appSettingsService;
|
final AppSettingsService _appSettingsService;
|
||||||
|
final AssetMediaRepository _assetMediaRepository;
|
||||||
final Logger _logger = Logger('ForegroundUploadService');
|
final Logger _logger = Logger('ForegroundUploadService');
|
||||||
|
|
||||||
bool shouldAbortUpload = false;
|
bool shouldAbortUpload = false;
|
||||||
@@ -311,7 +315,8 @@ class ForegroundUploadService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final originalFileName = entity.isLivePhoto ? p.setExtension(asset.name, p.extension(file.path)) : asset.name;
|
final fileName = await _assetMediaRepository.getOriginalFilename(asset.id) ?? asset.name;
|
||||||
|
final originalFileName = entity.isLivePhoto ? p.setExtension(fileName, p.extension(file.path)) : fileName;
|
||||||
final deviceId = Store.get(StoreKey.deviceId);
|
final deviceId = Store.get(StoreKey.deviceId);
|
||||||
|
|
||||||
final headers = ApiService.getRequestHeaders();
|
final headers = ApiService.getRequestHeaders();
|
||||||
@@ -322,19 +327,6 @@ class ForegroundUploadService {
|
|||||||
'fileModifiedAt': asset.updatedAt.toUtc().toIso8601String(),
|
'fileModifiedAt': asset.updatedAt.toUtc().toIso8601String(),
|
||||||
'isFavorite': asset.isFavorite.toString(),
|
'isFavorite': asset.isFavorite.toString(),
|
||||||
'duration': asset.duration.toString(),
|
'duration': asset.duration.toString(),
|
||||||
if (CurrentPlatform.isIOS && asset.cloudId != null)
|
|
||||||
'metadata': jsonEncode([
|
|
||||||
RemoteAssetMetadataItem(
|
|
||||||
key: RemoteAssetMetadataKey.mobileApp,
|
|
||||||
value: RemoteAssetMobileAppMetadata(
|
|
||||||
cloudId: asset.cloudId,
|
|
||||||
createdAt: asset.createdAt.toIso8601String(),
|
|
||||||
adjustmentTime: asset.adjustmentTime?.toIso8601String(),
|
|
||||||
latitude: asset.latitude?.toString(),
|
|
||||||
longitude: asset.longitude?.toString(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Upload live photo video first if available
|
// Upload live photo video first if available
|
||||||
@@ -363,6 +355,22 @@ class ForegroundUploadService {
|
|||||||
fields['livePhotoVideoId'] = livePhotoVideoId;
|
fields['livePhotoVideoId'] = livePhotoVideoId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add cloudId metadata only to the still image, not the motion video, becasue when the sync id happens, the motion video can get associated with the wrong still image.
|
||||||
|
if (CurrentPlatform.isIOS && asset.cloudId != null) {
|
||||||
|
fields['metadata'] = jsonEncode([
|
||||||
|
RemoteAssetMetadataItem(
|
||||||
|
key: RemoteAssetMetadataKey.mobileApp,
|
||||||
|
value: RemoteAssetMobileAppMetadata(
|
||||||
|
cloudId: asset.cloudId,
|
||||||
|
createdAt: asset.createdAt.toIso8601String(),
|
||||||
|
adjustmentTime: asset.adjustmentTime?.toIso8601String(),
|
||||||
|
latitude: asset.latitude?.toString(),
|
||||||
|
longitude: asset.longitude?.toString(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
final result = await _uploadRepository.uploadFile(
|
final result = await _uploadRepository.uploadFile(
|
||||||
file: file,
|
file: file,
|
||||||
originalFileName: originalFileName,
|
originalFileName: originalFileName,
|
||||||
|
|||||||
Reference in New Issue
Block a user