π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Cleanup
Manav Rathi740c1093ffa7
diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.tsindex 749166073b..f8aee67867 100644--- a/web/packages/gallery/services/download.ts+++ b/web/packages/gallery/services/download.ts@@ -18,7 +18,6 @@ import { customAPIOrigin } from "ente-base/origins";import {playableVideoBlob,renderableImageBlob,- type RenderableBlobOpts,} from "ente-gallery/utils/convert";import type { EnteFile } from "ente-media/file";import { FileType } from "ente-media/file-type";@@ -290,35 +289,21 @@ class DownloadManager {* (if possible).** See the documentation of {@link RenderableSourceURLs} for more details.- *- * The `forceConvert` option is true when the user presses the "Convert"- * button. See: [Note: Forcing conversion of playable videos].*/renderableSourceURLs = async (file: EnteFile,- opts?: RenderableBlobOpts,): Promise<RenderableSourceURLs> => {- // Keep a separate code path for when the conversion is not needed. The- // download will already be cached. The (lack of) conversion shouldn't- // be cached since some other code might also invoke us without setting- // the avoid conversion option.- if (opts?.avoidFormatConversion) {-- }-- if (!this.renderableSourceURLPromises.has(file.id)) {- this.renderableSourceURLPromises.set(- file.id,- createRenderableSourceURLs(- file,- this.fileURLDownloadAndCacheIfNeeded(file),- opts,- ),+ let promise = this.renderableSourceURLPromises.get(file.id);+ if (!promise) {+ promise = createRenderableSourceURLs(+ file,+ this.fileURLDownloadAndCacheIfNeeded(file),);+ this.renderableSourceURLPromises.set(file.id, promise);}try {- return await this.renderableSourceURLPromises.get(file.id)!;+ return await promise;} catch (e) {log.error("Failed to obtain renderableSourceURLs", e);this.renderableSourceURLPromises.delete(file.id);@@ -587,7 +572,6 @@ const wrapErrors = <T>(op: () => Promise<T>) =>const createRenderableSourceURLs = async (file: EnteFile,originalFileURLPromise: Promise<string>,- opts?: RenderableBlobOpts,): Promise<RenderableSourceURLs> => {const originalFileURL = await originalFileURLPromise;const fileBlob = await fetch(originalFileURL).then((res) => res.blob());@@ -609,11 +593,7 @@ const createRenderableSourceURLs = async (const fileName = file.metadata.title;switch (file.metadata.fileType) {case FileType.image: {- const convertedBlob = await renderableImageBlob(- fileBlob,- fileName,- opts,- );+ const convertedBlob = await renderableImageBlob(fileBlob, fileName);const convertedURL = existingOrNewObjectURL(convertedBlob);url = convertedURL;originalImageBlob = fileBlob;@@ -677,7 +657,6 @@ async function getRenderableLivePhotoURL(const convertedVideoBlob = await playableVideoBlob(livePhoto.videoFileName,videoBlob,- false,);if (!convertedVideoBlob) return undefined;return URL.createObjectURL(convertedVideoBlob);diff --git a/web/packages/gallery/utils/convert.ts b/web/packages/gallery/utils/convert.tsindex 81645bf1d0..3cb3dbc757 100644--- a/web/packages/gallery/utils/convert.ts+++ b/web/packages/gallery/utils/convert.ts@@ -17,8 +17,6 @@ import { detectFileTypeInfo } from "./detect-type";** @param fileName The name of the file whose data {@link imageBlob} is.*- * @param opts Options to tweak the conversion flowchart.- ** The logic used by this function is:** 1. Try to detect the MIME type of the file from its contents and/or name.@@ -170,8 +168,6 @@ export const playableVideoBlob = async (fileName: string, videoBlob: Blob) => {* Try to see if the browser thinks it can play the video pointed to by the* given {@link url} by creating a <video> element and initiating playback.*- * [Note: Forcing conversion of playable videos]- ** Note that this can sometimes cause false positives if the browser can play* some of the streams in the video, but not all. For example, the browser may* be able to play back the video stream, but not the audio stream (say due to@@ -179,10 +175,8 @@ export const playableVideoBlob = async (fileName: string, videoBlob: Blob) => {* to skip conversion, but when the user actually plays the video there will be* no sound.*- * As an escape hatch, we provide a force convert button in the UI for such- * cases, which'll cause the {@link forceConvert} flag in our caller function to- * be set. If so, it'll bypasses this preflight check we use to see if the- * browser can already play the video, and instead will always be transcoded.+ * To deal with such cases in an holistic manner, we have a streaming variant of+ * the video that gets transcoded into a (near) universal format.*/const isPlaybackPossible = async (url: string) =>new Promise((resolve) => {