This commit is contained in:
Manav Rathi 2024-04-23 18:54:34 +05:30
parent 190dc586a9
commit f96adddf54
No known key found for this signature in database
5 changed files with 15 additions and 67 deletions

View file

@ -70,11 +70,6 @@ export enum UPLOAD_STAGES {
FINISH,
}
export enum UPLOAD_STRATEGY {
SINGLE_COLLECTION,
COLLECTION_PER_FOLDER,
}
export enum UPLOAD_RESULT {
FAILED,
ALREADY_UPLOADED,

View file

@ -1,5 +1,5 @@
import { ensureElectron } from "@/next/electron";
import { basename, getFileNameSize } from "@/next/file";
import { getFileNameSize } from "@/next/file";
import log from "@/next/log";
import { ElectronFile } from "@/next/types/file";
import { DedicatedCryptoWorker } from "@ente/shared/crypto/internal/crypto.worker";
@ -17,7 +17,6 @@ import { getElectronFileStream, getFileStream } from "services/readerService";
import { getFileType } from "services/typeDetectionService";
import { FilePublicMagicMetadataProps } from "types/file";
import {
DataStream,
ExtractMetadataResult,
FileTypeInfo,
LivePhotoAssets,
@ -26,6 +25,7 @@ import {
ParsedExtractedMetadata,
ParsedMetadataJSON,
ParsedMetadataJSONMap,
type DataStream,
type FileWithCollection,
type FileWithCollection2,
type LivePhotoAssets2,
@ -34,7 +34,7 @@ import {
import { getFileTypeFromExtensionForLivePhotoClustering } from "utils/file/livePhoto";
import { getEXIFLocation, getEXIFTime, getParsedExifData } from "./exifService";
import uploadCancelService from "./uploadCancelService";
import { extractFileMetadata, getFileName } from "./uploadService";
import { getFileName } from "./uploadService";
const NULL_PARSED_METADATA_JSON: ParsedMetadataJSON = {
creationTime: null,

View file

@ -26,12 +26,10 @@ import {
import { EncryptedMagicMetadata } from "types/magicMetadata";
import {
BackupedFile,
DataStream,
EncryptedFile,
FileInMemory,
FileTypeInfo,
FileWithMetadata,
Logger,
MultipartUploadURLs,
ParsedMetadataJSONMap,
ProcessedFile,
@ -40,6 +38,7 @@ import {
UploadFile,
UploadURL,
isDataStream,
type DataStream,
type FileWithCollection2,
type LivePhotoAssets2,
type Metadata,
@ -250,6 +249,8 @@ const uploadService = new UploadService();
export default uploadService;
export type Logger = (message: string) => void;
interface UploadResponse {
fileUploadResult: UPLOAD_RESULT;
uploadedFile?: EnteFile;

View file

@ -13,17 +13,6 @@ import {
} from "types/file";
import { EncryptedMagicMetadata } from "types/magicMetadata";
export interface DataStream {
stream: ReadableStream<Uint8Array>;
chunkCount: number;
}
export function isDataStream(object: any): object is DataStream {
return "stream" in object;
}
export type Logger = (message: string) => void;
export interface Metadata {
/**
* The file name.
@ -112,6 +101,15 @@ export interface UploadURL {
objectKey: string;
}
export interface DataStream {
stream: ReadableStream<Uint8Array>;
chunkCount: number;
}
export function isDataStream(object: any): object is DataStream {
return "stream" in object;
}
export interface FileInMemory {
filedata: Uint8Array | DataStream;
/** The JPEG data of the generated thumbnail */

View file

@ -1,10 +1,3 @@
import type { Electron } from "./ipc";
export enum UPLOAD_STRATEGY {
SINGLE_COLLECTION,
COLLECTION_PER_FOLDER,
}
/*
* ElectronFile is a custom interface that is used to represent
* any file on disk as a File-like object in the Electron desktop app.
@ -23,45 +16,6 @@ export interface ElectronFile {
arrayBuffer: () => Promise<Uint8Array>;
}
/**
* A file path that we obtain from the Node.js layer of our desktop app.
*
* When a user drags and drops or otherwise interactively provides us with a
* file, we get an object that conforms to the [Web File
* API](https://developer.mozilla.org/en-US/docs/Web/API/File).
*
* However, we cannot programmatically create such File objects to arbitrary
* absolute paths on user's local filesystem for security reasons.
*
* This restricts us in cases where the user does want us to, say, watch a
* folder on disk for changes, or auto-resume previously interrupted uploads
* when the app gets restarted.
*
* For such functionality, we defer to our Node.js layer via the
* {@link Electron} object. This IPC communication works with absolute paths of
* disk files or folders, and the native Node.js layer can then perform the
* relevant operations on them.
*
* The {@link DesktopFilePath} interface bundles such a absolute {@link path}
* with an {@link Electron} object that we can later use to, say, read or write
* to that file by using the IPC methods.
*
* This is the same electron instance as `globalThis.electron`, except it is
* non-optional here. Thus we're guaranteed that whatever code is passing us an
* absolute file path is running in the context of our desktop app.
*/
export interface DesktopFilePath {
/** The absolute path to a file or a folder on the local filesystem. */
path: string;
/** The {@link Electron} instance that we can use to operate on the path. */
electron: Electron;
}
export interface DataStream {
stream: ReadableStream<Uint8Array>;
chunkCount: number;
}
export interface EventQueueItem {
type: "upload" | "trash";
folderPath: string;