Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mobile): Revert - upload motion and live part of LivePhotos together #5601

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions mobile/lib/modules/backup/services/backup.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ class BackupService {

req.files.add(assetRawUploadData);

if (entity.isLivePhoto) {
var livePhotoRawUploadData = await _getLivePhotoFile(entity);
if (livePhotoRawUploadData != null) {
req.files.add(livePhotoRawUploadData);
}
}

setCurrentUploadAssetCb(
CurrentUploadAsset(
id: entity.id,
Expand All @@ -325,29 +332,6 @@ class BackupService {
var response =
await httpClient.send(req, cancellationToken: cancelToken);

// Send live photo separately
if (entity.isLivePhoto) {
var livePhotoRawUploadData = await _getLivePhotoFile(entity);
if (livePhotoRawUploadData != null) {
var livePhotoReq = MultipartRequest(
req.method,
req.url,
onProgress: req.onProgress,
)
..headers.addAll(req.headers)
..fields.addAll(req.fields);

livePhotoReq.files.add(livePhotoRawUploadData);
// Send live photo only if the non-motion part is successful
if (response.statusCode == 200 || response.statusCode == 201) {
response = await httpClient.send(
livePhotoReq,
cancellationToken: cancelToken,
);
}
}
}

if (response.statusCode == 200) {
// asset is a duplicate (already exists on the server)
duplicatedAssetIds.add(entity.id);
Expand Down Expand Up @@ -405,7 +389,7 @@ class BackupService {
var fileStream = motionFile.openRead();
String fileName = p.basename(motionFile.path);
return http.MultipartFile(
"assetData",
"livePhotoData",
fileStream,
motionFile.lengthSync(),
filename: fileName,
Expand Down
Loading