π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
type merge
Manav Rathib93638e35413
diff --git a/web/apps/photos/src/components/Upload/UploadProgress/index.tsx b/web/apps/photos/src/components/Upload/UploadProgress/index.tsxindex 8f16ef2d98..1acffd561e 100644--- a/web/apps/photos/src/components/Upload/UploadProgress/index.tsx+++ b/web/apps/photos/src/components/Upload/UploadProgress/index.tsx@@ -1,18 +1,16 @@-import { useContext, useEffect, useState } from "react";-import { UploadProgressDialog } from "./dialog";-import { MinimizedUploadProgress } from "./minimized";--import { t } from "i18next";-import { UPLOAD_STAGES } from "constants/upload";import UploadProgressContext from "contexts/uploadProgress";+import { t } from "i18next";import { AppContext } from "pages/_app";-import {+import { useContext, useEffect, useState } from "react";+import type {InProgressUpload,SegregatedFinishedUploads,UploadCounter,UploadFileNames,-} from "types/upload/ui";+} from "services/upload/uploadManager";+import { UploadProgressDialog } from "./dialog";+import { MinimizedUploadProgress } from "./minimized";interface Props {open: boolean;diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsxindex 228f95f782..bf5b6e11bb 100644--- a/web/apps/photos/src/components/Upload/Uploader.tsx+++ b/web/apps/photos/src/components/Upload/Uploader.tsx@@ -19,6 +19,13 @@ import {getPublicCollectionUploaderName,savePublicCollectionUploaderName,} from "services/publicCollectionService";+import type {+ FileWithCollection,+ InProgressUpload,+ SegregatedFinishedUploads,+ UploadCounter,+ UploadFileNames,+} from "services/upload/uploadManager";import uploadManager, {setToUploadCollection,} from "services/upload/uploadManager";@@ -33,13 +40,6 @@ import {SetLoading,UploadTypeSelectorIntent,} from "types/gallery";-import { type FileWithCollection } from "types/upload";-import {- InProgressUpload,- SegregatedFinishedUploads,- UploadCounter,- UploadFileNames,-} from "types/upload/ui";import { getOrCreateAlbum } from "utils/collection";import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";import {diff --git a/web/apps/photos/src/constants/upload.ts b/web/apps/photos/src/constants/upload.tsindex faa8e586fb..2ff01810fc 100644--- a/web/apps/photos/src/constants/upload.ts+++ b/web/apps/photos/src/constants/upload.ts@@ -1,5 +1,5 @@import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/constants";-import { Location } from "types/upload";+import { Location } from "types/metadata";// this is the chunk size of the un-encrypted file which is read and encrypted before uploading it as a single part.export const MULTIPART_PART_SIZE = 20 * 1024 * 1024;diff --git a/web/apps/photos/src/contexts/uploadProgress.tsx b/web/apps/photos/src/contexts/uploadProgress.tsxindex fe5f733b86..b25df7d65b 100644--- a/web/apps/photos/src/contexts/uploadProgress.tsx+++ b/web/apps/photos/src/contexts/uploadProgress.tsx@@ -1,11 +1,11 @@import { UPLOAD_STAGES } from "constants/upload";import { createContext } from "react";-import {+import type {InProgressUpload,SegregatedFinishedUploads,UploadCounter,UploadFileNames,-} from "types/upload/ui";+} from "services/upload/uploadManager";interface UploadProgressContextType {open: boolean;diff --git a/web/apps/photos/src/services/exif.ts b/web/apps/photos/src/services/exif.tsindex 56c20a1c23..ef21a03f6a 100644--- a/web/apps/photos/src/services/exif.ts+++ b/web/apps/photos/src/services/exif.ts@@ -4,7 +4,7 @@ import { validateAndGetCreationUnixTimeInMicroSeconds } from "@ente/shared/time"import { NULL_LOCATION } from "constants/upload";import exifr from "exifr";import piexif from "piexifjs";-import { Location, type ParsedExtractedMetadata } from "types/upload";+import type { Location, ParsedExtractedMetadata } from "types/metadata";type ParsedEXIFData = Record<string, any> &Partial<{diff --git a/web/apps/photos/src/services/ffmpeg.ts b/web/apps/photos/src/services/ffmpeg.tsindex a89f9cd3d7..5f93172998 100644--- a/web/apps/photos/src/services/ffmpeg.ts+++ b/web/apps/photos/src/services/ffmpeg.ts@@ -9,8 +9,8 @@ import {outputPathPlaceholder,} from "constants/ffmpeg";import { NULL_LOCATION } from "constants/upload";-import { ParsedExtractedMetadata } from "types/upload";-import { type DedicatedFFmpegWorker } from "worker/ffmpeg.worker";+import type { ParsedExtractedMetadata } from "types/metadata";+import type { DedicatedFFmpegWorker } from "worker/ffmpeg.worker";/*** Generate a thumbnail for the given video using a wasm FFmpeg running in a webdiff --git a/web/apps/photos/src/services/locationSearchService.ts b/web/apps/photos/src/services/locationSearchService.tsindex 2aa2b6bacd..354c87a712 100644--- a/web/apps/photos/src/services/locationSearchService.ts+++ b/web/apps/photos/src/services/locationSearchService.ts@@ -1,6 +1,6 @@import log from "@/next/log";import { LocationTagData } from "types/entity";-import { Location } from "types/upload";+import { Location } from "types/metadata";export interface City {city: string;diff --git a/web/apps/photos/src/services/upload/takeout.ts b/web/apps/photos/src/services/upload/takeout.tsindex aa412c818f..5cd16130ef 100644--- a/web/apps/photos/src/services/upload/takeout.ts+++ b/web/apps/photos/src/services/upload/takeout.ts@@ -4,7 +4,7 @@ import { ensureElectron } from "@/next/electron";import { nameAndExtension } from "@/next/file";import log from "@/next/log";import { NULL_LOCATION } from "constants/upload";-import { type Location } from "types/upload";+import type { Location } from "types/metadata";export interface ParsedMetadataJSON {creationTime: number;@@ -124,7 +124,7 @@ const parseMetadataJSONText = (text: string) => {parsedMetadataJSON.modificationTime =metadataJSON["modificationTime"]["timestamp"] * 1000000;}- let locationData: Location = NULL_LOCATION;+ let locationData: Location = { ...NULL_LOCATION };if (metadataJSON["geoData"] &&(metadataJSON["geoData"]["latitude"] !== 0.0 ||diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.tsindex 64535517f2..0656ee69ee 100644--- a/web/apps/photos/src/services/upload/uploadManager.ts+++ b/web/apps/photos/src/services/upload/uploadManager.ts@@ -28,18 +28,6 @@ import watcher from "services/watch";import { Collection } from "types/collection";import { EncryptedEnteFile, EnteFile } from "types/file";import { SetFiles } from "types/gallery";-import {- FileWithCollection,- PublicUploadProps,- type LivePhotoAssets,-} from "types/upload";-import {- FinishedUploads,- InProgressUpload,- InProgressUploads,- ProgressUpdater,- SegregatedFinishedUploads,-} from "types/upload/ui";import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";import { getLocalFiles } from "../fileService";import {@@ -49,9 +37,70 @@ import {} from "./takeout";import UploadService, { fopFileName, fopSize, uploader } from "./uploadService";+export type FileID = number;++export type PercentageUploaded = number;+/* localID => fileName */+export type UploadFileNames = Map<FileID, string>;++export interface UploadCounter {+ finished: number;+ total: number;+}++export interface InProgressUpload {+ localFileID: FileID;+ progress: PercentageUploaded;+}++export interface FinishedUpload {+ localFileID: FileID;+ result: UPLOAD_RESULT;+}++export type InProgressUploads = Map<FileID, PercentageUploaded>;++export type FinishedUploads = Map<FileID, UPLOAD_RESULT>;++export type SegregatedFinishedUploads = Map<UPLOAD_RESULT, FileID[]>;++export interface ProgressUpdater {+ setPercentComplete: React.Dispatch<React.SetStateAction<number>>;+ setUploadCounter: React.Dispatch<React.SetStateAction<UploadCounter>>;+ setUploadStage: React.Dispatch<React.SetStateAction<UPLOAD_STAGES>>;+ setInProgressUploads: React.Dispatch<+ React.SetStateAction<InProgressUpload[]>+ >;+ setFinishedUploads: React.Dispatch<+ React.SetStateAction<SegregatedFinishedUploads>+ >;+ setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;+ setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;+ setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;+}+/** The number of uploads to process in parallel. */const maxConcurrentUploads = 4;+export interface FileWithCollection {+ localID: number;+ collectionID: number;+ isLivePhoto?: boolean;+ fileOrPath?: File | string;+ livePhotoAssets?: LivePhotoAssets;+}++export interface LivePhotoAssets {+ image: File | string;+ video: File | string;+}++export interface PublicUploadProps {+ token: string;+ passwordToken: string;+ accessedThroughSharedURL: boolean;+}+interface UploadCancelStatus {value: boolean;}diff --git a/web/apps/photos/src/services/upload/uploadService.ts b/web/apps/photos/src/services/upload/uploadService.tsindex e44a3c0740..4e0692b9c3 100644--- a/web/apps/photos/src/services/upload/uploadService.ts+++ b/web/apps/photos/src/services/upload/uploadService.ts@@ -26,6 +26,10 @@ import {import { addToCollection } from "services/collectionService";import { parseImageMetadata } from "services/exif";import * as ffmpeg from "services/ffmpeg";+import {+ PublicUploadProps,+ type LivePhotoAssets,+} from "services/upload/uploadManager";import {EnteFile,MetadataFileAttributes,@@ -35,11 +39,7 @@ import {type FilePublicMagicMetadataProps,} from "types/file";import { EncryptedMagicMetadata } from "types/magicMetadata";-import {- ParsedExtractedMetadata,- PublicUploadProps,- type LivePhotoAssets,-} from "types/upload";+import type { ParsedExtractedMetadata } from "types/metadata";import {getNonEmptyMagicMetadataProps,updateMagicMetadata,diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.tsindex be357019b4..29f5e22931 100644--- a/web/apps/photos/src/services/watch.ts+++ b/web/apps/photos/src/services/watch.ts@@ -14,10 +14,11 @@ import type {import { ensureString } from "@/utils/ensure";import { UPLOAD_RESULT } from "constants/upload";import debounce from "debounce";-import uploadManager from "services/upload/uploadManager";+import uploadManager, {+ type FileWithCollection,+} from "services/upload/uploadManager";import { Collection } from "types/collection";import { EncryptedEnteFile } from "types/file";-import { type FileWithCollection } from "types/upload";import { groupFilesBasedOnCollectionID } from "utils/file";import { isHiddenFile } from "utils/upload";import { removeFromCollection } from "./collectionService";diff --git a/web/apps/photos/src/types/entity.ts b/web/apps/photos/src/types/entity.tsindex 9580bf3332..60844ce466 100644--- a/web/apps/photos/src/types/entity.ts+++ b/web/apps/photos/src/types/entity.ts@@ -1,4 +1,4 @@-import { Location } from "types/upload";+import { Location } from "types/metadata";export enum EntityType {LOCATION_TAG = "location",diff --git a/web/apps/photos/src/types/metadata.ts b/web/apps/photos/src/types/metadata.tsnew file mode 100644index 0000000000..7994e62479--- /dev/null+++ b/web/apps/photos/src/types/metadata.ts@@ -0,0 +1,11 @@+export interface Location {+ latitude: number;+ longitude: number;+}++export interface ParsedExtractedMetadata {+ location: Location;+ creationTime: number;+ width: number;+ height: number;+}diff --git a/web/apps/photos/src/types/upload/index.ts b/web/apps/photos/src/types/upload/index.tsdeleted file mode 100644index 817a9dc102..0000000000--- a/web/apps/photos/src/types/upload/index.ts+++ /dev/null@@ -1,32 +0,0 @@-import type { ElectronFile } from "@/next/types/file";--export interface Location {- latitude: number;- longitude: number;-}--export interface FileWithCollection {- localID: number;- collectionID: number;- isLivePhoto?: boolean;- fileOrPath?: File | string;- livePhotoAssets?: LivePhotoAssets;-}--export interface LivePhotoAssets {- image: File | string;- video: File | string;-}--export interface ParsedExtractedMetadata {- location: Location;- creationTime: number;- width: number;- height: number;-}--export interface PublicUploadProps {- token: string;- passwordToken: string;- accessedThroughSharedURL: boolean;-}diff --git a/web/apps/photos/src/types/upload/ui.ts b/web/apps/photos/src/types/upload/ui.tsdeleted file mode 100644index bce381213f..0000000000--- a/web/apps/photos/src/types/upload/ui.ts+++ /dev/null@@ -1,43 +0,0 @@-import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";--export type FileID = number;-export type FileName = string;--export type PercentageUploaded = number;-export type UploadFileNames = Map<FileID, FileName>;--export interface UploadCounter {- finished: number;- total: number;-}--export interface InProgressUpload {- localFileID: FileID;- progress: PercentageUploaded;-}--export interface FinishedUpload {- localFileID: FileID;- result: UPLOAD_RESULT;-}--export type InProgressUploads = Map<FileID, PercentageUploaded>;--export type FinishedUploads = Map<FileID, UPLOAD_RESULT>;--export type SegregatedFinishedUploads = Map<UPLOAD_RESULT, FileID[]>;--export interface ProgressUpdater {- setPercentComplete: React.Dispatch<React.SetStateAction<number>>;- setUploadCounter: React.Dispatch<React.SetStateAction<UploadCounter>>;- setUploadStage: React.Dispatch<React.SetStateAction<UPLOAD_STAGES>>;- setInProgressUploads: React.Dispatch<- React.SetStateAction<InProgressUpload[]>- >;- setFinishedUploads: React.Dispatch<- React.SetStateAction<SegregatedFinishedUploads>- >;- setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;- setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;- setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;-}