Fail livephoto upload if videoUrl is missing
This commit is contained in:
parent
c602499837
commit
0ef4e5ad78
|
@ -1,5 +1,9 @@
|
|||
class InvalidFileError extends Error {}
|
||||
|
||||
class InvalidFileUploadState extends AssertionError {
|
||||
InvalidFileUploadState(String message) : super(message);
|
||||
}
|
||||
|
||||
class WiFiUnavailableError extends Error {}
|
||||
|
||||
class SyncStopRequestedError extends Error {}
|
||||
|
|
|
@ -72,11 +72,17 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(ente.File file) async {
|
|||
|
||||
if (file.fileType == FileType.livePhoto && io.Platform.isIOS) {
|
||||
final io.File videoUrl = await Motionphoto.getLivePhotoFile(file.localID);
|
||||
if (videoUrl == null || !videoUrl.existsSync()) {
|
||||
String errMsg = "missing livePhoto url for " + file.toString();
|
||||
_logger.severe(errMsg);
|
||||
throw InvalidFileUploadState(errMsg);
|
||||
}
|
||||
final tempPath = Configuration.instance.getTempDirectory();
|
||||
final zipFilePath = tempPath + file.generatedID.toString() + ".zip";
|
||||
_logger.fine("Uploading zipped live photo from " + zipFilePath);
|
||||
// .elv -> Ente live photo
|
||||
final livePhotoPath = tempPath + file.generatedID.toString() + ".elv";
|
||||
_logger.fine("Uploading zipped live photo from " + livePhotoPath);
|
||||
var encoder = ZipFileEncoder();
|
||||
encoder.create(zipFilePath);
|
||||
encoder.create(livePhotoPath);
|
||||
encoder.addFile(videoUrl, "video" + extension(videoUrl.path));
|
||||
encoder.addFile(sourceFile, "image" + extension(sourceFile.path));
|
||||
encoder.close();
|
||||
|
@ -85,7 +91,7 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(ente.File file) async {
|
|||
sourceFile.deleteSync();
|
||||
}
|
||||
// new sourceFile which needs to be uploaded
|
||||
sourceFile = io.File(zipFilePath);
|
||||
sourceFile = io.File(livePhotoPath);
|
||||
}
|
||||
|
||||
thumbnailData = await asset.thumbDataWithSize(
|
||||
|
|
Loading…
Reference in a new issue