Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Flip

Manav Rathi67ba7614dbb4
diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.ts
index 01e95df2a9..bce3d92bd0 100644
--- a/web/packages/gallery/services/download.ts
+++ b/web/packages/gallery/services/download.ts
@@ -42,7 +42,9 @@ export interface LoadedLivePhotoSourceURL {
* This structure originally arose as the source object URL, and a bunch of
* associated metadata, that the file viewer needs when the user wants to see
* the original file (as opposed to say, the thumbnail which we were showing
- * them earlier as the file is getting downloaded).
+ * them earlier as the file is getting downloaded). It is now also used in other
+ * places that need an as-close access to the original file as possible whilst
+ * still applying almost necessary conversions to be able to use that data.
*
* The word "renderable" is not a guarantee, but rather a best effort indicator
* as we might not always be able to convert all formats to something that the
@@ -547,7 +549,7 @@ const createRenderableSourceURLs = async (
const fileName = file.metadata.title;
switch (file.metadata.fileType) {
case FileType.image: {
- const convertedBlob = await renderableImageBlob(fileName, fileBlob);
+ const convertedBlob = await renderableImageBlob(fileBlob, fileName);
const convertedURL = existingOrNewObjectURL(convertedBlob);
url = convertedURL;
mimeType = convertedBlob.type;
@@ -602,7 +604,7 @@ async function getRenderableLivePhotoURL(
try {
const imageBlob = new Blob([livePhoto.imageData]);
return URL.createObjectURL(
- await renderableImageBlob(livePhoto.imageFileName, imageBlob),
+ await renderableImageBlob(imageBlob, livePhoto.imageFileName),
);
} catch {
//ignore and return null
diff --git a/web/packages/gallery/utils/convert.ts b/web/packages/gallery/utils/convert.ts
index f950039b02..4d5db902fd 100644
--- a/web/packages/gallery/utils/convert.ts
+++ b/web/packages/gallery/utils/convert.ts
@@ -23,10 +23,10 @@ let _isNativeJPEGConversionAvailable = true;
* The type of the returned blob is set, whenever possible, to the MIME type of
* the data that we're dealing with.
*
- * @param fileName The name of the file whose data is {@link imageBlob}.
- *
* @param imageBlob A {@link Blob} containing the contents of an image file.
*
+ * @param fileName The name of the file whose data {@link imageBlob} is.
+ *
* The logic used by this function is:
*
* 1. Try to detect the MIME type of the file from its contents and/or name.
@@ -48,8 +48,8 @@ let _isNativeJPEGConversionAvailable = true;
* In will catch all errors and return the original in those cases.
*/
export const renderableImageBlob = async (
- fileName: string,
imageBlob: Blob,
+ fileName: string,
) => {
try {
const file = new File([imageBlob], fileName);
diff --git a/web/packages/new/photos/services/ml/blob.ts b/web/packages/new/photos/services/ml/blob.ts
index 5a6fa8cc8a..cfab9eea1d 100644
--- a/web/packages/new/photos/services/ml/blob.ts
+++ b/web/packages/new/photos/services/ml/blob.ts
@@ -95,7 +95,7 @@ const fetchRenderableUploadItemBlob = async (
return new Blob([thumbnailData!]);
} else {
const blob = await readNonVideoUploadItem(uploadItem, electron);
- return renderableImageBlob(file.metadata.title, blob);
+ return renderableImageBlob(blob, file.metadata.title);
}
};
@@ -157,9 +157,9 @@ export const fetchRenderableEnteFileBlob = async (
file.metadata.title,
originalFileBlob,
);
- return renderableImageBlob(imageFileName, new Blob([imageData]));
+ return renderableImageBlob(new Blob([imageData]), imageFileName);
} else if (fileType == FileType.image) {
- return await renderableImageBlob(file.metadata.title, originalFileBlob);
+ return await renderableImageBlob(originalFileBlob, file.metadata.title);
} else {
// A layer above us should've already filtered these out.
throw new Error(`Cannot index unsupported file type ${fileType}`);