diff --git a/web/packages/gallery/services/upload.ts b/web/packages/gallery/services/upload.ts index c37f588fea..4b36f5743f 100644 --- a/web/packages/gallery/services/upload.ts +++ b/web/packages/gallery/services/upload.ts @@ -95,7 +95,7 @@ export const toDesktopUploadItem = ( uploadItem: UploadItem, ): DesktopUploadItem => { if (uploadItem instanceof File) { - log.warn("Invalid combination", { electron, uploadItem }); + log.info(`Invalid upload item (electron: ${!!electron})`, uploadItem); throw new Error( "Found a File upload item even though we're running in the desktop app", ); diff --git a/web/packages/gallery/services/video.ts b/web/packages/gallery/services/video.ts index 1bf2bf0fce..48bd05f087 100644 --- a/web/packages/gallery/services/video.ts +++ b/web/packages/gallery/services/video.ts @@ -21,7 +21,11 @@ import { getFilePreviewDataUploadURL, putVideoData, } from "./file-data"; -import type { UploadItem } from "./upload"; +import { + toDesktopUploadItem, + type DesktopUploadItem, + type UploadItem, +} from "./upload"; interface VideoProcessingQueueItem { /** @@ -30,12 +34,13 @@ interface VideoProcessingQueueItem { */ file: EnteFile; /** - * The {@link UploadItem} if available for the newly uploaded {@link file}. + * The {@link DesktopUploadItem} if available for the newly uploaded + * {@link file}. * * If present, this serves as an optimization allowing us to directly read * the file off the user's filesystem. */ - uploadItem: UploadItem | undefined; + uploadItem: DesktopUploadItem | undefined; } /** @@ -333,7 +338,7 @@ export const processVideoNewUpload = ( // (e.g. https://github.com/ffmpegwasm/ffmpeg.wasm/issues/851). // // So the video processing only happpens in the desktop app, which uses - // the much more efficient native ffmpeg integration. + // the much more efficient native FFmpeg integration. return; } @@ -346,7 +351,10 @@ export const processVideoNewUpload = ( } // Enqueue the item. - _state.videoProcessingQueue.push({ file, uploadItem }); + _state.videoProcessingQueue.push({ + file, + uploadItem: toDesktopUploadItem(electron, uploadItem), + }); // Tickle the processor if it isn't already running. _state.queueProcessor ??= processQueue(electron); diff --git a/web/packages/gallery/utils/native-stream.ts b/web/packages/gallery/utils/native-stream.ts index 2bc566609e..1ac52e58fe 100644 --- a/web/packages/gallery/utils/native-stream.ts +++ b/web/packages/gallery/utils/native-stream.ts @@ -8,7 +8,7 @@ import type { Electron, ElectronMLWorker, ZipItem } from "ente-base/types/ipc"; import { z } from "zod"; -import type { UploadItem } from "../services/upload"; +import type { DesktopUploadItem } from "../services/upload"; /** * Stream the given file or zip entry from the user's local file system. @@ -188,7 +188,7 @@ export type GenerateHLSResult = z.infer; * * @returns a token that can be used to retrieve the generated HLS playlist, and * metadata about the generated video (its byte size and dimensions). See {@link - * GenerateHLSResult. + * GenerateHLSResult}. * * In case the video is such that it doesn't require a separate stream to be * generated (e.g. it is a small video using an already compatible codec), then @@ -198,7 +198,7 @@ export type GenerateHLSResult = z.infer; */ export const initiateGenerateHLS = async ( _: Electron, - video: UploadItem | ReadableStream, + video: DesktopUploadItem | ReadableStream, objectUploadURL: string, ): Promise => { const params = new URLSearchParams({ op: "generate-hls", objectUploadURL }); @@ -217,11 +217,6 @@ export const initiateGenerateHLS = async ( const [zipPath, entryName] = video; params.set("zipPath", zipPath); params.set("entryName", entryName); - } else if (video instanceof File) { - // A drag and dropped file, but without a path. This is a browser - // specific case which shouldn't happen when we're running in the - // desktop app. Bail. - throw new Error("Unexpected file without path"); } else { // A File with a path. Use the path. params.set("path", video.path);