diff --git a/web/apps/photos/src/components/Upload/UploadProgress/dialog.tsx b/web/apps/photos/src/components/Upload/UploadProgress/dialog.tsx index da7f488f25..ded9e2c17f 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/dialog.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/dialog.tsx @@ -1,7 +1,10 @@ import { Dialog, DialogContent, Link } from "@mui/material"; import { t } from "i18next"; -import { UPLOAD_RESULT, UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { + UPLOAD_RESULT, + UPLOAD_STAGES, +} from "@/new/photos/services/upload/types"; import { dialogCloseHandler } from "@ente/shared/components/DialogBox/TitleWithCloseButton"; import UploadProgressContext from "contexts/uploadProgress"; import { useContext, useEffect, useState } from "react"; diff --git a/web/apps/photos/src/components/Upload/UploadProgress/footer.tsx b/web/apps/photos/src/components/Upload/UploadProgress/footer.tsx index 6359009a9a..7372392032 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/footer.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/footer.tsx @@ -1,4 +1,7 @@ -import { UPLOAD_RESULT, UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { + UPLOAD_RESULT, + UPLOAD_STAGES, +} from "@/new/photos/services/upload/types"; import { Button, DialogActions } from "@mui/material"; import { t } from "i18next"; import { useContext } from "react"; diff --git a/web/apps/photos/src/components/Upload/UploadProgress/inProgressSection.tsx b/web/apps/photos/src/components/Upload/UploadProgress/inProgressSection.tsx index fba1a51db5..327cc43723 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/inProgressSection.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/inProgressSection.tsx @@ -11,7 +11,7 @@ import { } from "./section"; import { InProgressItemContainer } from "./styledComponents"; -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import { CaptionedText } from "components/CaptionedText"; export const InProgressSection = () => { diff --git a/web/apps/photos/src/components/Upload/UploadProgress/index.tsx b/web/apps/photos/src/components/Upload/UploadProgress/index.tsx index da5fde0950..3dc9d6cea8 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/index.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/index.tsx @@ -1,4 +1,4 @@ -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import UploadProgressContext from "contexts/uploadProgress"; import { t } from "i18next"; import { AppContext } from "pages/_app"; diff --git a/web/apps/photos/src/components/Upload/UploadProgress/progressBar.tsx b/web/apps/photos/src/components/Upload/UploadProgress/progressBar.tsx index ba28ac7e19..a18d9d7aa9 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/progressBar.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/progressBar.tsx @@ -1,4 +1,4 @@ -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import { Box, Divider, LinearProgress } from "@mui/material"; import UploadProgressContext from "contexts/uploadProgress"; import { useContext } from "react"; diff --git a/web/apps/photos/src/components/Upload/UploadProgress/resultSection.tsx b/web/apps/photos/src/components/Upload/UploadProgress/resultSection.tsx index 93926fcf0e..6c483bf49c 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/resultSection.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/resultSection.tsx @@ -1,4 +1,4 @@ -import { UPLOAD_RESULT } from "@/new/photos/constants/upload"; +import { UPLOAD_RESULT } from "@/new/photos/services/upload/types"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import { CaptionedText } from "components/CaptionedText"; import ItemList from "components/ItemList"; diff --git a/web/apps/photos/src/components/Upload/UploadProgress/title.tsx b/web/apps/photos/src/components/Upload/UploadProgress/title.tsx index a123b4c009..332ef57483 100644 --- a/web/apps/photos/src/components/Upload/UploadProgress/title.tsx +++ b/web/apps/photos/src/components/Upload/UploadProgress/title.tsx @@ -1,4 +1,4 @@ -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import { IconButtonWithBG, SpaceBetweenFlex, diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx index 8afe1a41d1..767b32c35d 100644 --- a/web/apps/photos/src/components/Upload/Uploader.tsx +++ b/web/apps/photos/src/components/Upload/Uploader.tsx @@ -1,5 +1,9 @@ -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; import { exportMetadataDirectoryName } from "@/new/photos/services/export"; +import type { + FileAndPath, + UploadItem, +} from "@/new/photos/services/upload/types"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import { basename } from "@/next/file"; import log from "@/next/log"; import type { CollectionMapping, Electron, ZipItem } from "@/next/types/ipc"; @@ -21,7 +25,6 @@ import { getPublicCollectionUploaderName, savePublicCollectionUploaderName, } from "services/publicCollectionService"; -import type { FileAndPath, UploadItem } from "services/upload/types"; import type { InProgressUpload, SegregatedFinishedUploads, diff --git a/web/apps/photos/src/contexts/uploadProgress.tsx b/web/apps/photos/src/contexts/uploadProgress.tsx index 440ec75c6d..1c98569b03 100644 --- a/web/apps/photos/src/contexts/uploadProgress.tsx +++ b/web/apps/photos/src/contexts/uploadProgress.tsx @@ -1,4 +1,4 @@ -import { UPLOAD_STAGES } from "@/new/photos/constants/upload"; +import { UPLOAD_STAGES } from "@/new/photos/services/upload/types"; import { createContext } from "react"; import type { InProgressUpload, diff --git a/web/apps/photos/src/services/exif.ts b/web/apps/photos/src/services/exif.ts index eed1f5ee17..d483dec745 100644 --- a/web/apps/photos/src/services/exif.ts +++ b/web/apps/photos/src/services/exif.ts @@ -1,5 +1,5 @@ import { type FileTypeInfo } from "@/media/file-type"; -import { NULL_LOCATION } from "@/new/photos/constants/upload"; +import { NULL_LOCATION } from "@/new/photos/services/upload/types"; import type { Location, ParsedExtractedMetadata, diff --git a/web/apps/photos/src/services/ffmpeg.ts b/web/apps/photos/src/services/ffmpeg.ts index ded7a5baff..0d98e96a29 100644 --- a/web/apps/photos/src/services/ffmpeg.ts +++ b/web/apps/photos/src/services/ffmpeg.ts @@ -1,4 +1,9 @@ -import { NULL_LOCATION } from "@/new/photos/constants/upload"; +import { + NULL_LOCATION, + toDataOrPathOrZipEntry, + type DesktopUploadItem, + type UploadItem, +} from "@/new/photos/services/upload/types"; import type { ParsedExtractedMetadata } from "@/new/photos/types/metadata"; import { readConvertToMP4Done, @@ -15,11 +20,6 @@ import { outputPathPlaceholder, } from "constants/ffmpeg"; import type { DedicatedFFmpegWorker } from "worker/ffmpeg.worker"; -import { - toDataOrPathOrZipEntry, - type DesktopUploadItem, - type UploadItem, -} from "./upload/types"; /** * Generate a thumbnail for the given video using a wasm FFmpeg running in a web diff --git a/web/apps/photos/src/services/upload/takeout.ts b/web/apps/photos/src/services/upload/takeout.ts index f2bcdee38b..e0b1307ed9 100644 --- a/web/apps/photos/src/services/upload/takeout.ts +++ b/web/apps/photos/src/services/upload/takeout.ts @@ -1,12 +1,12 @@ /** @file Dealing with the JSON metadata in Google Takeouts */ -import { NULL_LOCATION } from "@/new/photos/constants/upload"; +import type { UploadItem } from "@/new/photos/services/upload/types"; +import { NULL_LOCATION } from "@/new/photos/services/upload/types"; import type { Location } from "@/new/photos/types/metadata"; import { readStream } from "@/new/photos/utils/native-stream"; import { ensureElectron } from "@/next/electron"; import { nameAndExtension } from "@/next/file"; import log from "@/next/log"; -import type { UploadItem } from "./types"; export interface ParsedMetadataJSON { creationTime: number; diff --git a/web/apps/photos/src/services/upload/thumbnail.ts b/web/apps/photos/src/services/upload/thumbnail.ts index 91260131d3..f40e1fefeb 100644 --- a/web/apps/photos/src/services/upload/thumbnail.ts +++ b/web/apps/photos/src/services/upload/thumbnail.ts @@ -1,12 +1,15 @@ import { FILE_TYPE, type FileTypeInfo } from "@/media/file-type"; import { heicToJPEG } from "@/media/heic-convert"; import { scaledImageDimensions } from "@/media/image"; +import { + toDataOrPathOrZipEntry, + type DesktopUploadItem, +} from "@/new/photos/services/upload/types"; import log from "@/next/log"; import { type Electron } from "@/next/types/ipc"; import { ensure } from "@/utils/ensure"; import { withTimeout } from "@/utils/promise"; import * as ffmpeg from "services/ffmpeg"; -import { toDataOrPathOrZipEntry, type DesktopUploadItem } from "./types"; /** Maximum width or height of the generated thumbnail */ const maxThumbnailDimension = 720; diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts index be4ced8a92..b66b2ebf8f 100644 --- a/web/apps/photos/src/services/upload/uploadManager.ts +++ b/web/apps/photos/src/services/upload/uploadManager.ts @@ -1,11 +1,12 @@ import { FILE_TYPE } from "@/media/file-type"; import { potentialFileTypeFromExtension } from "@/media/live-photo"; +import { getLocalFiles } from "@/new/photos/services/files"; +import type { UploadItem } from "@/new/photos/services/upload/types"; import { RANDOM_PERCENTAGE_PROGRESS_FOR_PUT, UPLOAD_RESULT, UPLOAD_STAGES, -} from "@/new/photos/constants/upload"; -import { getLocalFiles } from "@/new/photos/services/files"; +} from "@/new/photos/services/upload/types"; import { EncryptedEnteFile, EnteFile } from "@/new/photos/types/file"; import { ensureElectron } from "@/next/electron"; import { lowercaseExtension, nameAndExtension } from "@/next/file"; @@ -35,7 +36,6 @@ import { tryParseTakeoutMetadataJSON, type ParsedMetadataJSON, } from "./takeout"; -import type { UploadItem } from "./types"; import UploadService, { uploadItemFileName, uploader } from "./uploadService"; export type FileID = number; diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.ts index 81cf6645f8..c4057feff5 100644 --- a/web/apps/photos/src/services/upload/uploadService.ts +++ b/web/apps/photos/src/services/upload/uploadService.ts @@ -2,11 +2,12 @@ import { hasFileHash } from "@/media/file"; import { FILE_TYPE, type FileTypeInfo } from "@/media/file-type"; import { encodeLivePhoto } from "@/media/live-photo"; import type { Metadata } from "@/media/types/file"; +import type { UploadItem } from "@/new/photos/services/upload/types"; import { NULL_LOCATION, RANDOM_PERCENTAGE_PROGRESS_FOR_PUT, UPLOAD_RESULT, -} from "@/new/photos/constants/upload"; +} from "@/new/photos/services/upload/types"; import { EnteFile, MetadataFileAttributes, @@ -50,7 +51,6 @@ import { generateThumbnailNative, generateThumbnailWeb, } from "./thumbnail"; -import type { UploadItem } from "./types"; import UploadHttpClient from "./uploadHttpClient"; import type { UploadableUploadItem } from "./uploadManager"; diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.ts index 2e9519dbf5..8c367ee71c 100644 --- a/web/apps/photos/src/services/watch.ts +++ b/web/apps/photos/src/services/watch.ts @@ -3,8 +3,8 @@ * watch folders functionality. */ -import { UPLOAD_RESULT } from "@/new/photos/constants/upload"; import { getLocalFiles } from "@/new/photos/services/files"; +import { UPLOAD_RESULT } from "@/new/photos/services/upload/types"; import { EncryptedEnteFile } from "@/new/photos/types/file"; import { ensureElectron } from "@/next/electron"; import { basename, dirname } from "@/next/file"; diff --git a/web/packages/new/photos/constants/upload.ts b/web/packages/new/photos/constants/upload.ts deleted file mode 100644 index fcee4df18c..0000000000 --- a/web/packages/new/photos/constants/upload.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Location } from "../types/metadata"; - -export const RANDOM_PERCENTAGE_PROGRESS_FOR_PUT = () => 90 + 10 * Math.random(); - -export const NULL_LOCATION: Location = { latitude: null, longitude: null }; - -export enum UPLOAD_STAGES { - START, - READING_GOOGLE_METADATA_FILES, - EXTRACTING_METADATA, - UPLOADING, - CANCELLING, - FINISH, -} - -export enum UPLOAD_RESULT { - FAILED, - ALREADY_UPLOADED, - UNSUPPORTED, - BLOCKED, - TOO_LARGE, - LARGER_THAN_AVAILABLE_STORAGE, - UPLOADED, - UPLOADED_WITH_STATIC_THUMBNAIL, - ADDED_SYMLINK, -} diff --git a/web/apps/photos/src/services/upload/types.ts b/web/packages/new/photos/services/upload/types.ts similarity index 81% rename from web/apps/photos/src/services/upload/types.ts rename to web/packages/new/photos/services/upload/types.ts index 25e2ab408a..f11ba90961 100644 --- a/web/apps/photos/src/services/upload/types.ts +++ b/web/packages/new/photos/services/upload/types.ts @@ -1,4 +1,5 @@ import type { ZipItem } from "@/next/types/ipc"; +import type { Location } from "../../types/metadata"; /** * An item to upload is one of the following: @@ -55,3 +56,28 @@ 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 const NULL_LOCATION: Location = { latitude: null, longitude: null }; + +export enum UPLOAD_STAGES { + START, + READING_GOOGLE_METADATA_FILES, + EXTRACTING_METADATA, + UPLOADING, + CANCELLING, + FINISH, +} + +export enum UPLOAD_RESULT { + FAILED, + ALREADY_UPLOADED, + UNSUPPORTED, + BLOCKED, + TOO_LARGE, + LARGER_THAN_AVAILABLE_STORAGE, + UPLOADED, + UPLOADED_WITH_STATIC_THUMBNAIL, + ADDED_SYMLINK, +}