mirror of
https://github.com/ente-io/ente.git
synced 2025-08-07 15:09:09 +00:00
Move
This commit is contained in:
parent
396065e80c
commit
f8c2f4b9dd
@ -1,9 +1,6 @@
|
||||
import { FilledIconButton } from "@/base/components/mui";
|
||||
import { useBaseContext } from "@/base/context";
|
||||
import {
|
||||
UPLOAD_RESULT,
|
||||
type UploadPhase,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import { UPLOAD_RESULT, type UploadPhase } from "@/gallery/services/upload";
|
||||
import { SpaceBetweenFlex } from "@ente/shared/components/Container";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
|
@ -4,6 +4,11 @@ import { useBaseContext } from "@/base/context";
|
||||
import { basename } from "@/base/file-name";
|
||||
import log from "@/base/log";
|
||||
import type { CollectionMapping, Electron, ZipItem } from "@/base/types/ipc";
|
||||
import type {
|
||||
FileAndPath,
|
||||
UploadItem,
|
||||
UploadPhase,
|
||||
} from "@/gallery/services/upload";
|
||||
import type { Collection } from "@/media/collection";
|
||||
import type { EnteFile } from "@/media/file";
|
||||
import { UploaderNameInput } from "@/new/albums/components/UploaderNameInput";
|
||||
@ -12,11 +17,6 @@ import type { CollectionSelectorAttributes } from "@/new/photos/components/Colle
|
||||
import { downloadAppDialogAttributes } from "@/new/photos/components/utils/download";
|
||||
import { getLatestCollections } from "@/new/photos/services/collections";
|
||||
import { exportMetadataDirectoryName } from "@/new/photos/services/export";
|
||||
import type {
|
||||
FileAndPath,
|
||||
UploadItem,
|
||||
UploadPhase,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import { redirectToCustomerPortal } from "@/new/photos/services/user-details";
|
||||
import { usePhotosAppContext } from "@/new/photos/types/context";
|
||||
import { firstNonEmpty } from "@/utils/array";
|
||||
|
@ -5,8 +5,8 @@ import { ensureElectron } from "@/base/electron";
|
||||
import { nameAndExtension } from "@/base/file-name";
|
||||
import log from "@/base/log";
|
||||
import { type Location } from "@/base/types";
|
||||
import type { UploadItem } from "@/gallery/services/upload";
|
||||
import { readStream } from "@/gallery/utils/native-stream";
|
||||
import type { UploadItem } from "@/new/photos/services/upload/types";
|
||||
import { maybeParseInt } from "@/utils/parse";
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,14 @@
|
||||
import log from "@/base/log";
|
||||
import { type Electron } from "@/base/types/ipc";
|
||||
import * as ffmpeg from "@/gallery/services/ffmpeg";
|
||||
import {
|
||||
toDataOrPathOrZipEntry,
|
||||
type DesktopUploadItem,
|
||||
} from "@/gallery/services/upload";
|
||||
import { FileType, type FileTypeInfo } from "@/media/file-type";
|
||||
import { isHEICExtension } from "@/media/formats";
|
||||
import { heicToJPEG } from "@/media/heic-convert";
|
||||
import { scaledImageDimensions } from "@/media/image";
|
||||
import {
|
||||
toDataOrPathOrZipEntry,
|
||||
type DesktopUploadItem,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import { withTimeout } from "@/utils/promise";
|
||||
|
||||
/** Maximum width or height of the generated thumbnail */
|
||||
|
@ -10,6 +10,11 @@ import {
|
||||
getNonEmptyMagicMetadataProps,
|
||||
updateMagicMetadata,
|
||||
} from "@/gallery/services/magic-metadata";
|
||||
import type { UploadItem } from "@/gallery/services/upload";
|
||||
import {
|
||||
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
|
||||
UPLOAD_RESULT,
|
||||
} from "@/gallery/services/upload";
|
||||
import {
|
||||
detectFileTypeInfoFromChunk,
|
||||
isFileTypeNotSupportedError,
|
||||
@ -34,11 +39,6 @@ import { FileType, type FileTypeInfo } from "@/media/file-type";
|
||||
import { encodeLivePhoto } from "@/media/live-photo";
|
||||
import { addToCollection } from "@/new/photos/services/collection";
|
||||
import { extractExif } from "@/new/photos/services/exif";
|
||||
import type { UploadItem } from "@/new/photos/services/upload/types";
|
||||
import {
|
||||
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
|
||||
UPLOAD_RESULT,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import { mergeUint8Arrays } from "@/utils/array";
|
||||
import { ensureInteger, ensureNumber } from "@/utils/ensure";
|
||||
import { CustomError, handleUploadError } from "@ente/shared/error";
|
||||
|
@ -6,7 +6,13 @@ import type { PublicAlbumsCredentials } from "@/base/http";
|
||||
import log from "@/base/log";
|
||||
import type { Electron } from "@/base/types/ipc";
|
||||
import { ComlinkWorker } from "@/base/worker/comlink-worker";
|
||||
import { shouldDisableCFUploadProxy } from "@/gallery/services/upload";
|
||||
import type { UploadItem } from "@/gallery/services/upload";
|
||||
import {
|
||||
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
|
||||
UPLOAD_RESULT,
|
||||
shouldDisableCFUploadProxy,
|
||||
type UploadPhase,
|
||||
} from "@/gallery/services/upload";
|
||||
import type { Collection } from "@/media/collection";
|
||||
import {
|
||||
decryptFile,
|
||||
@ -18,12 +24,6 @@ import { FileType } from "@/media/file-type";
|
||||
import { potentialFileTypeFromExtension } from "@/media/live-photo";
|
||||
import { getLocalFiles } from "@/new/photos/services/files";
|
||||
import { indexNewUpload } from "@/new/photos/services/ml";
|
||||
import type { UploadItem } from "@/new/photos/services/upload/types";
|
||||
import {
|
||||
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
|
||||
UPLOAD_RESULT,
|
||||
type UploadPhase,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import { wait } from "@/utils/promise";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import { Canceler } from "axios";
|
||||
|
@ -11,13 +11,13 @@ import type {
|
||||
FolderWatch,
|
||||
FolderWatchSyncedFile,
|
||||
} from "@/base/types/ipc";
|
||||
import { UPLOAD_RESULT } from "@/gallery/services/upload";
|
||||
import type { Collection } from "@/media/collection";
|
||||
import { EncryptedEnteFile } from "@/media/file";
|
||||
import {
|
||||
getLocalFiles,
|
||||
groupFilesByCollectionID,
|
||||
} from "@/new/photos/services/files";
|
||||
import { UPLOAD_RESULT } from "@/new/photos/services/upload/types";
|
||||
import { ensureString } from "@/utils/ensure";
|
||||
import debounce from "debounce";
|
||||
import uploadManager, {
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { ensureElectron } from "@/base/electron";
|
||||
import log from "@/base/log";
|
||||
import type { Electron } from "@/base/types/ipc";
|
||||
import {
|
||||
toDataOrPathOrZipEntry,
|
||||
type DesktopUploadItem,
|
||||
type UploadItem,
|
||||
} from "@/gallery/services/upload";
|
||||
import {
|
||||
readConvertToMP4Done,
|
||||
readConvertToMP4Stream,
|
||||
writeConvertToMP4Stream,
|
||||
} from "@/gallery/utils/native-stream";
|
||||
import { parseMetadataDate, type ParsedMetadata } from "@/media/file-metadata";
|
||||
import {
|
||||
toDataOrPathOrZipEntry,
|
||||
type DesktopUploadItem,
|
||||
type UploadItem,
|
||||
} from "@/new/photos/services/upload/types";
|
||||
import {
|
||||
ffmpegPathPlaceholder,
|
||||
inputPathPlaceholder,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import log from "@/base/log";
|
||||
import { customAPIOrigin } from "@/base/origins";
|
||||
import type { ZipItem } from "@/base/types/ipc";
|
||||
import { nullToUndefined } from "@/utils/transform";
|
||||
import { z } from "zod";
|
||||
|
||||
@ -28,6 +29,83 @@ export const resetUploadState = () => {
|
||||
_state = new UploadState();
|
||||
};
|
||||
|
||||
/**
|
||||
* An item to upload is one of the following:
|
||||
*
|
||||
* 1. A file drag-and-dropped or selected by the user when we are running in the
|
||||
* web browser. These is the {@link File} case.
|
||||
*
|
||||
* 2. A file drag-and-dropped or selected by the user when we are running in the
|
||||
* context of our desktop app. In such cases, we also have the absolute path
|
||||
* of the file in the user's local file system. This is the
|
||||
* {@link FileAndPath} case.
|
||||
*
|
||||
* 3. A file path programmatically requested by the desktop app. For example, we
|
||||
* might be resuming a previously interrupted upload after an app restart
|
||||
* (thus we no longer have access to the {@link File} from case 2). Or we
|
||||
* could be uploading a file this is in one of the folders the user has asked
|
||||
* us to watch for changes. This is the `string` case.
|
||||
*
|
||||
* 4. A file within a zip file on the user's local file system. This too is only
|
||||
* possible when we are running in the context of our desktop app. The user
|
||||
* might have drag-and-dropped or selected a zip file, or it might be a zip
|
||||
* file that they'd previously selected but we now are resuming an
|
||||
* interrupted upload of. Either ways, what we have is a tuple containing the
|
||||
* (path to zip file, and the name of an entry within that zip file). This is
|
||||
* the {@link ZipItem} case.
|
||||
*
|
||||
* Also see: [Note: Reading a UploadItem].
|
||||
*/
|
||||
export type UploadItem = File | FileAndPath | string | ZipItem;
|
||||
|
||||
/**
|
||||
* When we are running in the context of our desktop app, we have access to the
|
||||
* absolute path of {@link File} objects. This convenience type clubs these two
|
||||
* bits of information, saving us the need to query the path again and again
|
||||
* using the {@link getPathForFile} method of {@link Electron}.
|
||||
*/
|
||||
export interface FileAndPath {
|
||||
file: File;
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The of cases of {@link UploadItem} that apply when we're running in the
|
||||
* context of our desktop app.
|
||||
*/
|
||||
export type DesktopUploadItem = Exclude<UploadItem, File>;
|
||||
|
||||
/**
|
||||
* For each of cases of {@link UploadItem} that apply when we're running in the
|
||||
* context of our desktop app, return a value that can be passed to
|
||||
* {@link Electron} functions over IPC.
|
||||
*/
|
||||
export const toDataOrPathOrZipEntry = (desktopUploadItem: DesktopUploadItem) =>
|
||||
typeof desktopUploadItem == "string" || Array.isArray(desktopUploadItem)
|
||||
? desktopUploadItem
|
||||
: desktopUploadItem.path;
|
||||
|
||||
export const RANDOM_PERCENTAGE_PROGRESS_FOR_PUT = () => 90 + 10 * Math.random();
|
||||
|
||||
export type UploadPhase =
|
||||
| "preparing"
|
||||
| "readingMetadata"
|
||||
| "uploading"
|
||||
| "cancelling"
|
||||
| "done";
|
||||
|
||||
export enum UPLOAD_RESULT {
|
||||
FAILED,
|
||||
ALREADY_UPLOADED,
|
||||
UNSUPPORTED,
|
||||
BLOCKED,
|
||||
TOO_LARGE,
|
||||
LARGER_THAN_AVAILABLE_STORAGE,
|
||||
UPLOADED,
|
||||
UPLOADED_WITH_STATIC_THUMBNAIL,
|
||||
ADDED_SYMLINK,
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true to disable the upload of files via Cloudflare Workers.
|
||||
*
|
||||
|
@ -1,78 +0,0 @@
|
||||
import type { ZipItem } from "@/base/types/ipc";
|
||||
|
||||
/**
|
||||
* An item to upload is one of the following:
|
||||
*
|
||||
* 1. A file drag-and-dropped or selected by the user when we are running in the
|
||||
* web browser. These is the {@link File} case.
|
||||
*
|
||||
* 2. A file drag-and-dropped or selected by the user when we are running in the
|
||||
* context of our desktop app. In such cases, we also have the absolute path
|
||||
* of the file in the user's local file system. This is the
|
||||
* {@link FileAndPath} case.
|
||||
*
|
||||
* 3. A file path programmatically requested by the desktop app. For example, we
|
||||
* might be resuming a previously interrupted upload after an app restart
|
||||
* (thus we no longer have access to the {@link File} from case 2). Or we
|
||||
* could be uploading a file this is in one of the folders the user has asked
|
||||
* us to watch for changes. This is the `string` case.
|
||||
*
|
||||
* 4. A file within a zip file on the user's local file system. This too is only
|
||||
* possible when we are running in the context of our desktop app. The user
|
||||
* might have drag-and-dropped or selected a zip file, or it might be a zip
|
||||
* file that they'd previously selected but we now are resuming an
|
||||
* interrupted upload of. Either ways, what we have is a tuple containing the
|
||||
* (path to zip file, and the name of an entry within that zip file). This is
|
||||
* the {@link ZipItem} case.
|
||||
*
|
||||
* Also see: [Note: Reading a UploadItem].
|
||||
*/
|
||||
export type UploadItem = File | FileAndPath | string | ZipItem;
|
||||
|
||||
/**
|
||||
* When we are running in the context of our desktop app, we have access to the
|
||||
* absolute path of {@link File} objects. This convenience type clubs these two
|
||||
* bits of information, saving us the need to query the path again and again
|
||||
* using the {@link getPathForFile} method of {@link Electron}.
|
||||
*/
|
||||
export interface FileAndPath {
|
||||
file: File;
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The of cases of {@link UploadItem} that apply when we're running in the
|
||||
* context of our desktop app.
|
||||
*/
|
||||
export type DesktopUploadItem = Exclude<UploadItem, File>;
|
||||
|
||||
/**
|
||||
* For each of cases of {@link UploadItem} that apply when we're running in the
|
||||
* context of our desktop app, return a value that can be passed to
|
||||
* {@link Electron} functions over IPC.
|
||||
*/
|
||||
export const toDataOrPathOrZipEntry = (desktopUploadItem: DesktopUploadItem) =>
|
||||
typeof desktopUploadItem == "string" || Array.isArray(desktopUploadItem)
|
||||
? desktopUploadItem
|
||||
: desktopUploadItem.path;
|
||||
|
||||
export const RANDOM_PERCENTAGE_PROGRESS_FOR_PUT = () => 90 + 10 * Math.random();
|
||||
|
||||
export type UploadPhase =
|
||||
| "preparing"
|
||||
| "readingMetadata"
|
||||
| "uploading"
|
||||
| "cancelling"
|
||||
| "done";
|
||||
|
||||
export enum UPLOAD_RESULT {
|
||||
FAILED,
|
||||
ALREADY_UPLOADED,
|
||||
UNSUPPORTED,
|
||||
BLOCKED,
|
||||
TOO_LARGE,
|
||||
LARGER_THAN_AVAILABLE_STORAGE,
|
||||
UPLOADED,
|
||||
UPLOADED_WITH_STATIC_THUMBNAIL,
|
||||
ADDED_SYMLINK,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user