mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
Merge 80e540681b into e7d6a066f8
This commit is contained in:
commit
61936c9268
2 changed files with 12 additions and 4 deletions
|
|
@ -36,7 +36,8 @@ class StorageRepository {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final entity = await AssetEntity.fromId(asset.id);
|
final entity = await AssetEntity.fromId(asset.id);
|
||||||
file = await entity?.originFileWithSubtype;
|
// Use a timeout to avoid hanging on Live Photos whose paired video is unavailable (e.g., shared albums)
|
||||||
|
file = await entity?.originFileWithSubtype.timeout(const Duration(seconds: 5));
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
log.warning(
|
log.warning(
|
||||||
"Cannot get motion file for asset ${asset.id}, name: ${asset.name}, created on: ${asset.createdAt}",
|
"Cannot get motion file for asset ${asset.id}, name: ${asset.name}, created on: ${asset.createdAt}",
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,7 @@ class UploadService {
|
||||||
}
|
}
|
||||||
|
|
||||||
File? file;
|
File? file;
|
||||||
|
bool uploadAsLive = entity.isLivePhoto;
|
||||||
|
|
||||||
/// iOS LivePhoto has two files: a photo and a video.
|
/// iOS LivePhoto has two files: a photo and a video.
|
||||||
/// They are uploaded separately, with video file being upload first, then returned with the assetId
|
/// They are uploaded separately, with video file being upload first, then returned with the assetId
|
||||||
|
|
@ -314,8 +315,14 @@ class UploadService {
|
||||||
/// The cancel operation will only cancel the video group (normal group), the photo group will not
|
/// The cancel operation will only cancel the video group (normal group), the photo group will not
|
||||||
/// be touched, as the video file is already uploaded.
|
/// be touched, as the video file is already uploaded.
|
||||||
|
|
||||||
if (entity.isLivePhoto) {
|
if (uploadAsLive) {
|
||||||
file = await _storageRepository.getMotionFileForAsset(asset);
|
file = await _storageRepository.getMotionFileForAsset(asset);
|
||||||
|
// Fallback: if motion video is unavailable (e.g., shared album or old format), upload still photo only
|
||||||
|
if (file == null) {
|
||||||
|
_logger.warning('Live Photo motion file missing for ${asset.id} (${asset.name}); uploading still image only');
|
||||||
|
file = await _storageRepository.getFileForAsset(asset.id);
|
||||||
|
uploadAsLive = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
file = await _storageRepository.getFileForAsset(asset.id);
|
file = await _storageRepository.getFileForAsset(asset.id);
|
||||||
}
|
}
|
||||||
|
|
@ -324,11 +331,11 @@ class UploadService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final originalFileName = entity.isLivePhoto ? p.setExtension(asset.name, p.extension(file.path)) : asset.name;
|
final originalFileName = uploadAsLive ? p.setExtension(asset.name, p.extension(file.path)) : asset.name;
|
||||||
|
|
||||||
String metadata = UploadTaskMetadata(
|
String metadata = UploadTaskMetadata(
|
||||||
localAssetId: asset.id,
|
localAssetId: asset.id,
|
||||||
isLivePhotos: entity.isLivePhoto,
|
isLivePhotos: uploadAsLive,
|
||||||
livePhotoVideoId: '',
|
livePhotoVideoId: '',
|
||||||
).toJson();
|
).toJson();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue