This commit is contained in:
Manav Rathi 2024-10-15 08:40:46 +05:30
parent d2db4c9cfa
commit 80f5cf0f66
No known key found for this signature in database
58 changed files with 293 additions and 300 deletions

View File

@ -9,16 +9,16 @@ import { sharedCryptoWorker } from "@/base/crypto";
import { nameAndExtension } from "@/base/file";
import log from "@/base/log";
import { apiURL, customAPIOrigin } from "@/base/origins";
import { FileType } from "@/media/file-type";
import { isHEICExtension, needsJPEGConversion } from "@/media/formats";
import { heicToJPEG } from "@/media/heic-convert";
import { decodeLivePhoto } from "@/media/live-photo";
import type {
EncryptedEnteFile,
EnteFile,
FileMagicMetadata,
FilePublicMagicMetadata,
} from "@/new/photos/types/file";
} from "@/media/file";
import { FileType } from "@/media/file-type";
import { isHEICExtension, needsJPEGConversion } from "@/media/formats";
import { heicToJPEG } from "@/media/heic-convert";
import { decodeLivePhoto } from "@/media/live-photo";
import { mergeMetadata1 } from "@/new/photos/utils/file";
import { shuffled } from "@/utils/array";
import { ensure } from "@/utils/ensure";

View File

@ -1,4 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { SpaceBetweenFlex } from "@ente/shared/components/Container";
import { formatDateTime } from "@ente/shared/time/format";
import {

View File

@ -1,7 +1,7 @@
import { EnteSwitch } from "@/base/components/EnteSwitch";
import log from "@/base/log";
import { EnteFile } from "@/media/file";
import { AppContext } from "@/new/photos/types/context";
import { EnteFile } from "@/new/photos/types/file";
import ChangeDirectoryOption from "@ente/shared/components/ChangeDirectoryOption";
import {
SpaceBetweenFlex,

View File

@ -1,7 +1,7 @@
import { TitledMiniDialog } from "@/base/components/MiniDialog";
import { FocusVisibleButton } from "@/base/components/mui/FocusVisibleButton";
import { EnteFile } from "@/media/file";
import { ItemCard, PreviewItemTile } from "@/new/photos/components/Tiles";
import { EnteFile } from "@/new/photos/types/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import { Box, styled } from "@mui/material";
import ItemList from "components/ItemList";

View File

@ -1,4 +1,5 @@
import log from "@/base/log";
import { EnteFile } from "@/media/file";
import {
decryptPublicMagicMetadata,
fileCreationPhotoDate,
@ -9,7 +10,6 @@ import { FileType } from "@/media/file-type";
import { PhotoDateTimePicker } from "@/new/photos/components/PhotoDateTimePicker";
import downloadManager from "@/new/photos/services/download";
import { extractExifDates } from "@/new/photos/services/exif";
import { EnteFile } from "@/new/photos/types/file";
import { fileLogID } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import DialogBox from "@ente/shared/components/DialogBox/";

View File

@ -1,9 +1,9 @@
import log from "@/base/log";
import type { LivePhotoSourceURL, SourceURLs } from "@/media/file";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import type { GalleryBarMode } from "@/new/photos/components/gallery/BarImpl";
import DownloadManager from "@/new/photos/services/download";
import type { LivePhotoSourceURL, SourceURLs } from "@/new/photos/types/file";
import { EnteFile } from "@/new/photos/types/file";
import { PHOTOS_PAGES } from "@ente/shared/constants/pages";
import { CustomError } from "@ente/shared/error";
import useMemoSingleThreaded from "@ente/shared/hooks/useMemoSingleThreaded";

View File

@ -1,10 +1,10 @@
import { EnteFile } from "@/media/file";
import {
GAP_BTW_TILES,
IMAGE_CONTAINER_MAX_HEIGHT,
IMAGE_CONTAINER_MAX_WIDTH,
MIN_COLUMNS,
} from "@/new/photos/components/PhotoList";
import { EnteFile } from "@/new/photos/types/file";
import { formattedByteSize } from "@/new/photos/utils/units";
import { FlexWrapper } from "@ente/shared/components/Container";
import { Box, styled } from "@mui/material";

View File

@ -1,4 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { formattedByteSize } from "@/new/photos/utils/units";
import { FlexWrapper } from "@ente/shared/components/Container";
import { formatDate } from "@ente/shared/time/format";

View File

@ -1,5 +1,5 @@
import log from "@/base/log";
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import Close from "@mui/icons-material/Close";
import Done from "@mui/icons-material/Done";

View File

@ -7,6 +7,7 @@ import { useModalVisibility } from "@/base/components/utils/modal";
import { nameAndExtension } from "@/base/file";
import log from "@/base/log";
import type { Location } from "@/base/types";
import { EnteFile } from "@/media/file";
import type { ParsedMetadata } from "@/media/file-metadata";
import {
fileCreationPhotoDate,
@ -29,7 +30,6 @@ import {
type AnnotatedFaceID,
} from "@/new/photos/services/ml";
import { AppContext } from "@/new/photos/types/context";
import { EnteFile } from "@/new/photos/types/file";
import { formattedByteSize } from "@/new/photos/utils/units";
import CopyButton from "@ente/shared/components/CodeBlock/CopyButton";
import { FlexWrapper } from "@ente/shared/components/Container";

View File

@ -7,10 +7,10 @@ import {
import type { MiniDialogAttributes } from "@/base/components/MiniDialog";
import { nameAndExtension } from "@/base/file";
import log from "@/base/log";
import { EnteFile } from "@/media/file";
import { photosDialogZIndex } from "@/new/photos/components/z-index";
import downloadManager from "@/new/photos/services/download";
import { AppContext } from "@/new/photos/types/context";
import { EnteFile } from "@/new/photos/types/file";
import { downloadAndRevokeObjectURL } from "@/new/photos/utils/web";
import { ensure } from "@/utils/ensure";
import {

View File

@ -2,13 +2,13 @@ import { isDesktop } from "@/base/app";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
import { lowercaseExtension } from "@/base/file";
import log from "@/base/log";
import type { LoadedLivePhotoSourceURL } from "@/media/file";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { isHEICExtension, needsJPEGConversion } from "@/media/formats";
import downloadManager from "@/new/photos/services/download";
import { extractRawExif, parseExif } from "@/new/photos/services/exif";
import { AppContext } from "@/new/photos/types/context";
import type { LoadedLivePhotoSourceURL } from "@/new/photos/types/file";
import { EnteFile } from "@/new/photos/types/file";
import { fileLogID } from "@/new/photos/utils/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import AlbumOutlined from "@mui/icons-material/AlbumOutlined";

View File

@ -1,5 +1,5 @@
import log from "@/base/log";
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { styled, useTheme } from "@mui/material";
import { GalleryContext } from "pages/gallery";
import React, { useContext, useLayoutEffect, useState } from "react";

View File

@ -1,4 +1,5 @@
import log from "@/base/log";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import {
GAP_BTW_TILES,
@ -9,7 +10,6 @@ import {
StaticThumbnail,
} from "@/new/photos/components/PlaceholderThumbnails";
import DownloadManager from "@/new/photos/services/download";
import { EnteFile } from "@/new/photos/types/file";
import { Overlay } from "@ente/shared/components/Container";
import { CustomError } from "@ente/shared/error";
import useLongPress from "@ente/shared/hooks/useLongPress";

View File

@ -5,6 +5,7 @@ import { useModalVisibility } from "@/base/components/utils/modal";
import { useIsSmallWidth } from "@/base/hooks";
import log from "@/base/log";
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
import {
CollectionSelector,
type CollectionSelectorAttributes,
@ -37,7 +38,6 @@ import {
} from "@/new/photos/services/search";
import type { SearchOption } from "@/new/photos/services/search/types";
import { AppContext } from "@/new/photos/types/context";
import { EnteFile } from "@/new/photos/types/file";
import { mergeMetadata } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import {

View File

@ -5,6 +5,7 @@ import { sharedCryptoWorker } from "@/base/crypto";
import { useIsSmallWidth, useIsTouchscreen } from "@/base/hooks";
import log from "@/base/log";
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
import {
GalleryItemsHeaderAdapter,
GalleryItemsSummary,
@ -13,7 +14,6 @@ import { SpaceBetweenFlex } from "@/new/photos/components/mui";
import downloadManager from "@/new/photos/services/download";
import { sortFiles } from "@/new/photos/services/files";
import { AppContext } from "@/new/photos/types/context";
import { EnteFile } from "@/new/photos/types/file";
import { mergeMetadata } from "@/new/photos/utils/file";
import {
CenteredFlex,

View File

@ -19,6 +19,7 @@ import {
SUB_TYPE,
UpdatePublicURL,
} from "@/media/collection";
import { EncryptedMagicMetadata, EnteFile } from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
import type {
CollectionSummaries,
@ -30,7 +31,6 @@ import {
CollectionsSortBy,
} from "@/new/photos/services/collection/ui";
import { getLocalFiles, sortFiles } from "@/new/photos/services/files";
import { EncryptedMagicMetadata, EnteFile } from "@/new/photos/types/file";
import { batch } from "@/utils/array";
import { CustomError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";

View File

@ -1,9 +1,8 @@
import log from "@/base/log";
import { apiURL } from "@/base/origins";
import { hasFileHash } from "@/media/file";
import { EnteFile, hasFileHash } from "@/media/file";
import type { Metadata } from "@/media/file-metadata";
import { FileType } from "@/media/file-type";
import { EnteFile } from "@/new/photos/types/file";
import HTTPService from "@ente/shared/network/HTTPService";
import { getToken } from "@ente/shared/storage/localStorage/helpers";

View File

@ -1,6 +1,7 @@
import { ensureElectron } from "@/base/electron";
import log from "@/base/log";
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
import {
fileCreationPhotoDate,
fileLocation,
@ -15,7 +16,6 @@ import {
exportTrashDirectoryName,
} from "@/new/photos/services/export";
import { getAllLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import { mergeMetadata } from "@/new/photos/utils/file";
import { safeDirectoryName, safeFileName } from "@/new/photos/utils/native-fs";
import { writeStream } from "@/new/photos/utils/native-stream";

View File

@ -2,12 +2,12 @@ import { ensureElectron } from "@/base/electron";
import { nameAndExtension } from "@/base/file";
import log from "@/base/log";
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import downloadManager from "@/new/photos/services/download";
import { exportMetadataDirectoryName } from "@/new/photos/services/export";
import { getAllLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import { mergeMetadata } from "@/new/photos/utils/file";
import {
safeDirectoryName,

View File

@ -2,20 +2,20 @@ import { encryptMetadataJSON } from "@/base/crypto";
import log from "@/base/log";
import { apiURL } from "@/base/origins";
import type { Collection } from "@/media/collection";
import {
clearCachedThumbnailsIfChanged,
getLocalFiles,
setLocalFiles,
sortFiles,
} from "@/new/photos/services/files";
import type { EncryptedMagicMetadata } from "@/new/photos/types/file";
import type { EncryptedMagicMetadata } from "@/media/file";
import {
EncryptedEnteFile,
EnteFile,
FileWithUpdatedMagicMetadata,
FileWithUpdatedPublicMagicMetadata,
TrashRequest,
} from "@/new/photos/types/file";
} from "@/media/file";
import {
clearCachedThumbnailsIfChanged,
getLocalFiles,
setLocalFiles,
sortFiles,
} from "@/new/photos/services/files";
import { mergeMetadata } from "@/new/photos/utils/file";
import { batch } from "@/utils/array";
import HTTPService from "@ente/shared/network/HTTPService";

View File

@ -5,8 +5,8 @@ import type {
Collection,
CollectionPublicMagicMetadata,
} from "@/media/collection";
import { EncryptedEnteFile, EnteFile } from "@/media/file";
import { sortFiles } from "@/new/photos/services/files";
import { EncryptedEnteFile, EnteFile } from "@/new/photos/types/file";
import { mergeMetadata } from "@/new/photos/utils/file";
import { CustomError, parseSharingErrorCodes } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";

View File

@ -1,12 +1,12 @@
import log from "@/base/log";
import { apiURL } from "@/base/origins";
import type { Collection } from "@/media/collection";
import { EncryptedTrashItem, Trash } from "@/media/file";
import {
getLocalTrash,
getTrashedFiles,
TRASH,
} from "@/new/photos/services/files";
import { EncryptedTrashItem, Trash } from "@/new/photos/types/file";
import HTTPService from "@ente/shared/network/HTTPService";
import localForage from "@ente/shared/storage/localForage";
import { getToken } from "@ente/shared/storage/localStorage/helpers";

View File

@ -1,6 +1,6 @@
import log from "@/base/log";
import { apiURL } from "@/base/origins";
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { CustomError, handleUploadError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";
import { MultipartUploadURLs, UploadFile, UploadURL } from "./upload-service";

View File

@ -7,7 +7,16 @@ import { ensureElectron } from "@/base/electron";
import { basename, nameAndExtension } from "@/base/file";
import log from "@/base/log";
import { CustomErrorMessage } from "@/base/types/ipc";
import { hasFileHash } from "@/media/file";
import {
EncryptedMagicMetadata,
EnteFile,
hasFileHash,
MetadataFileAttributes,
S3FileAttributes,
type EncryptedEnteFile,
type FilePublicMagicMetadata,
type FilePublicMagicMetadataProps,
} from "@/media/file";
import type {
Metadata,
ParsedMetadata,
@ -22,15 +31,6 @@ import {
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
UPLOAD_RESULT,
} from "@/new/photos/services/upload/types";
import {
EncryptedMagicMetadata,
EnteFile,
MetadataFileAttributes,
S3FileAttributes,
type EncryptedEnteFile,
type FilePublicMagicMetadata,
type FilePublicMagicMetadataProps,
} from "@/new/photos/types/file";
import { detectFileTypeInfoFromChunk } from "@/new/photos/utils/detect-type";
import { readStream } from "@/new/photos/utils/native-stream";
import { ensure, ensureInteger, ensureNumber } from "@/utils/ensure";

View File

@ -1,6 +1,6 @@
import log from "@/base/log";
import { apiURL, uploaderOrigin } from "@/base/origins";
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { wait } from "@/utils/promise";
import { CustomError, handleUploadError } from "@ente/shared/error";
import HTTPService from "@ente/shared/network/HTTPService";

View File

@ -5,6 +5,7 @@ import log from "@/base/log";
import type { Electron } from "@/base/types/ipc";
import { ComlinkWorker } from "@/base/worker/comlink-worker";
import type { Collection } from "@/media/collection";
import { EncryptedEnteFile, EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { potentialFileTypeFromExtension } from "@/media/live-photo";
import { getLocalFiles, sortFiles } from "@/new/photos/services/files";
@ -15,7 +16,6 @@ import {
UPLOAD_RESULT,
UPLOAD_STAGES,
} from "@/new/photos/services/upload/types";
import { EncryptedEnteFile, EnteFile } from "@/new/photos/types/file";
import { ensure } from "@/utils/ensure";
import { wait } from "@/utils/promise";
import { CustomError } from "@ente/shared/error";

View File

@ -12,9 +12,9 @@ import type {
FolderWatchSyncedFile,
} from "@/base/types/ipc";
import type { Collection } from "@/media/collection";
import { EncryptedEnteFile } from "@/media/file";
import { getLocalFiles } from "@/new/photos/services/files";
import { UPLOAD_RESULT } from "@/new/photos/services/upload/types";
import { EncryptedEnteFile } from "@/new/photos/types/file";
import { ensureString } from "@/utils/ensure";
import debounce from "debounce";
import uploadManager, {

View File

@ -1,4 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import type { ExportStage } from "services/export";
export interface ExportProgress {

View File

@ -1,6 +1,6 @@
import type { Collection } from "@/media/collection";
import { EnteFile } from "@/media/file";
import { type SelectionContext } from "@/new/photos/components/gallery";
import { EnteFile } from "@/new/photos/types/file";
import type { User } from "@ente/shared/user/types";
import { FilesDownloadProgressAttributes } from "components/FilesDownloadProgress";
import { TimeStampListItem } from "components/PhotoList";

View File

@ -1,5 +1,5 @@
import type { PublicURL } from "@/media/collection";
import { EnteFile } from "@/new/photos/types/file";
import { EnteFile } from "@/media/file";
import { TimeStampListItem } from "components/PhotoList";
export interface PublicCollectionGalleryContextType {

View File

@ -8,9 +8,9 @@ import {
CollectionType,
SUB_TYPE,
} from "@/media/collection";
import { EnteFile } from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
import { getAllLocalFiles, getLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import { safeDirectoryName } from "@/new/photos/utils/native-fs";
import { CustomError } from "@ente/shared/error";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";

View File

@ -1,11 +1,6 @@
import { sharedCryptoWorker } from "@/base/crypto";
import log from "@/base/log";
import { type Electron } from "@/base/types/ipc";
import { ItemVisibility } from "@/media/file-metadata";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import DownloadManager from "@/new/photos/services/download";
import { updateExifIfNeededAndPossible } from "@/new/photos/services/exif-update";
import {
EncryptedEnteFile,
EnteFile,
@ -14,7 +9,12 @@ import {
FilePublicMagicMetadata,
FilePublicMagicMetadataProps,
FileWithUpdatedMagicMetadata,
} from "@/new/photos/types/file";
} from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import DownloadManager from "@/new/photos/services/download";
import { updateExifIfNeededAndPossible } from "@/new/photos/services/exif-update";
import { detectFileTypeInfo } from "@/new/photos/utils/detect-type";
import { mergeMetadata } from "@/new/photos/utils/file";
import { safeFileName } from "@/new/photos/utils/native-fs";

View File

@ -1,7 +1,7 @@
import { sharedCryptoWorker } from "@/base/crypto";
import type { Collection } from "@/media/collection";
import { EnteFile, MagicMetadataCore } from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
import { EnteFile, MagicMetadataCore } from "@/new/photos/types/file";
export function isArchivedFile(item: EnteFile): boolean {
if (!item || !item.magicMetadata || !item.magicMetadata.data) {

View File

@ -1,9 +1,9 @@
import log from "@/base/log";
import type { LivePhotoSourceURL, SourceURLs } from "@/media/file";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import type { SelectionContext } from "@/new/photos/components/gallery";
import type { GalleryBarMode } from "@/new/photos/components/gallery/BarImpl";
import type { LivePhotoSourceURL, SourceURLs } from "@/new/photos/types/file";
import { EnteFile } from "@/new/photos/types/file";
import { ensure } from "@/utils/ensure";
import { SetSelectedState } from "types/gallery";

View File

@ -1,9 +1,9 @@
import { ItemVisibility } from "@/media/file-metadata";
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
import {
type EncryptedMagicMetadata,
type MagicMetadataCore,
} from "@/new/photos/types/file";
} from "@/media/file";
import { ItemVisibility } from "@/media/file-metadata";
// TODO: Audit this file

View File

@ -2,10 +2,7 @@ import { decryptMetadataJSON, encryptMetadataJSON } from "@/base/crypto";
import { authenticatedRequestHeaders, ensureOk } from "@/base/http";
import { apiURL } from "@/base/origins";
import { type Location } from "@/base/types";
import {
type EnteFile,
type FilePublicMagicMetadata,
} from "@/new/photos/types/file";
import { type EnteFile, type FilePublicMagicMetadata } from "@/media/file";
import { mergeMetadata1 } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import { nullToUndefined } from "@/utils/transform";

View File

@ -1,4 +1,210 @@
import type { Metadata } from "./file-metadata";
import { type Metadata, ItemVisibility } from "./file-metadata";
// TODO: Audit this file.
export interface MetadataFileAttributes {
encryptedData: string;
decryptionHeader: string;
}
export interface S3FileAttributes {
objectKey: string;
decryptionHeader: string;
}
export interface FileInfo {
fileSize: number;
thumbSize: number;
}
export interface MagicMetadataCore<T> {
version: number;
count: number;
header: string;
data: T;
}
export type EncryptedMagicMetadata = MagicMetadataCore<string>;
export interface EncryptedEnteFile {
id: number;
collectionID: number;
ownerID: number;
file: S3FileAttributes;
thumbnail: S3FileAttributes;
metadata: MetadataFileAttributes;
info: FileInfo | undefined;
magicMetadata: EncryptedMagicMetadata;
pubMagicMetadata: EncryptedMagicMetadata;
encryptedKey: string;
keyDecryptionNonce: string;
isDeleted: boolean;
updationTime: number;
}
export interface EnteFile
extends Omit<
EncryptedEnteFile,
| "metadata"
| "pubMagicMetadata"
| "magicMetadata"
| "encryptedKey"
| "keyDecryptionNonce"
> {
metadata: Metadata;
magicMetadata: FileMagicMetadata;
/**
* The envelope containing the public magic metadata associated with this
* file.
*
* In almost all cases, files will have associated public magic metadata
* since newer clients have something or the other they need to add to it.
* But its presence is not guaranteed.
*/
pubMagicMetadata?: FilePublicMagicMetadata;
isTrashed?: boolean;
/**
* The base64 encoded encryption key associated with this file.
*
* This key is used to encrypt both the file's contents, and any associated
* data (e.g., metadatum, thumbnail) for the file.
*/
key: string;
src?: string;
srcURLs?: SourceURLs;
msrc?: string;
html?: string;
w?: number;
h?: number;
title?: string;
deleteBy?: number;
isSourceLoaded?: boolean;
conversionFailed?: boolean;
isConverted?: boolean;
}
export interface LivePhotoSourceURL {
image: () => Promise<string | undefined>;
video: () => Promise<string | undefined>;
}
export interface LoadedLivePhotoSourceURL {
image: string;
video: string;
}
export interface SourceURLs {
url: string | LivePhotoSourceURL | LoadedLivePhotoSourceURL;
isOriginal: boolean;
isRenderable: boolean;
type: "normal" | "livePhoto";
/**
* Best effort attempt at obtaining the MIME type.
*
* Known cases where it is missing:
*
* - Live photos (these have a different code path for obtaining the URL).
* - A video that is passes the isPlayable test in the browser.
*
*/
mimeType?: string;
}
export interface TrashRequest {
items: TrashRequestItems[];
}
export interface TrashRequestItems {
fileID: number;
collectionID: number;
}
export interface FileWithUpdatedMagicMetadata {
file: EnteFile;
updatedMagicMetadata: FileMagicMetadata;
}
export interface FileWithUpdatedPublicMagicMetadata {
file: EnteFile;
updatedPublicMagicMetadata: FilePublicMagicMetadata;
}
export interface FileMagicMetadataProps {
/**
* The visibility of the file
*
* The file's visibility is user specific attribute, and thus we keep it in
* the private magic metadata. This allows the file's owner to share a file
* and edit its visibility without making revealing their visibility
* preference to the people with whom they have shared the file.
*/
visibility?: ItemVisibility;
filePaths?: string[];
}
export type FileMagicMetadata = MagicMetadataCore<FileMagicMetadataProps>;
export interface FilePublicMagicMetadataProps {
/**
* Modified value of the date time associated with an {@link EnteFile}.
*
* Epoch microseconds.
*/
editedTime?: number;
/**
* Edited name of the {@link EnteFile}.
*
* If the user edits the name of the file within Ente, then the edits are
* saved in this field.
*/
editedName?: string;
/**
* A arbitrary textual caption / description that the user has attached to
* the {@link EnteFile}.
*/
caption?: string;
uploaderName?: string;
/**
* Width of the image / video, in pixels.
*/
w?: number;
/**
* Height of the image / video, in pixels.
*/
h?: number;
/**
* Edited latitude for the {@link EnteFile}.
*
* If the user edits the location (latitude and longitude) of a file within
* Ente, then the edits will be stored as the {@link lat} and {@link long}
* properties in the file's public magic metadata.
*/
lat?: number;
/**
* Edited longitude for the {@link EnteFile}.
*
* See {@link long}.
*/
long?: number;
}
export type FilePublicMagicMetadata =
MagicMetadataCore<FilePublicMagicMetadataProps>;
export interface TrashItem extends Omit<EncryptedTrashItem, "file"> {
file: EnteFile;
}
export interface EncryptedTrashItem {
file: EncryptedEnteFile;
isDeleted: boolean;
isRestored: boolean;
deleteBy: number;
createdAt: number;
updatedAt: number;
}
export type Trash = TrashItem[];
export const hasFileHash = (file: Metadata) =>
!!file.hash || (!!file.imageHash && !!file.videoHash);

View File

@ -1,8 +1,8 @@
import { useIsSmallWidth } from "@/base/hooks";
import { pt } from "@/base/i18n";
import type { EnteFile } from "@/media/file";
import { faceCrop, type AnnotatedFaceID } from "@/new/photos/services/ml";
import type { Person, PreviewableFace } from "@/new/photos/services/ml/people";
import type { EnteFile } from "@/new/photos/types/file";
import { Skeleton, Typography, styled } from "@mui/material";
import { t } from "i18next";
import React, { useEffect, useState } from "react";

View File

@ -1,9 +1,9 @@
import { type EnteFile } from "@/media/file";
import {
LoadingThumbnail,
StaticThumbnail,
} from "@/new/photos/components/PlaceholderThumbnails";
import downloadManager from "@/new/photos/services/download";
import { type EnteFile } from "@/new/photos/types/file";
import { styled } from "@mui/material";
import React, { useEffect, useState } from "react";
import { faceCrop } from "../services/ml";

View File

@ -1,4 +1,4 @@
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
export type CollectionSummaryType =
| "folder"

View File

@ -7,14 +7,10 @@ import { sharedCryptoWorker } from "@/base/crypto";
import { type CryptoWorker } from "@/base/crypto/worker";
import log from "@/base/log";
import { customAPIOrigin } from "@/base/origins";
import type { EnteFile, LivePhotoSourceURL, SourceURLs } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import * as ffmpeg from "@/new/photos/services/ffmpeg";
import type {
EnteFile,
LivePhotoSourceURL,
SourceURLs,
} from "@/new/photos/types/file";
import { renderableImageBlob } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import { CustomError } from "@ente/shared/error";

View File

@ -1,8 +1,8 @@
import { lowercaseExtension } from "@/base/file";
import log from "@/base/log";
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import piexif from "piexifjs";
import type { EnteFile } from "../types/file";
/**
* Return a new stream after applying Exif updates if applicable to the given

View File

@ -1,7 +1,7 @@
import { encryptBlobB64 } from "@/base/crypto";
import { authenticatedRequestHeaders, ensureOk } from "@/base/http";
import { apiURL } from "@/base/origins";
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
import { z } from "zod";
/**

View File

@ -1,7 +1,7 @@
import { blobCache } from "@/base/blob-cache";
import { type EnteFile, type Trash } from "@/media/file";
import { FileType } from "@/media/file-type";
import localForage from "@ente/shared/storage/localForage";
import { type EnteFile, type Trash } from "../types/file";
import { mergeMetadata } from "../utils/file";
const FILES_TABLE = "files";

View File

@ -1,9 +1,9 @@
import { basename } from "@/base/file";
import type { ElectronMLWorker } from "@/base/types/ipc";
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import { ensure } from "@/utils/ensure";
import type { EnteFile } from "../../types/file";
import { renderableImageBlob } from "../../utils/file";
import { readStream } from "../../utils/native-stream";
import DownloadManager from "../download";

View File

@ -1,9 +1,9 @@
import { assertionFailed } from "@/base/assert";
import { newNonSecureID } from "@/base/id-worker";
import log from "@/base/log";
import type { EnteFile } from "@/media/file";
import { ensure } from "@/utils/ensure";
import { wait } from "@/utils/promise";
import type { EnteFile } from "../../types/file";
import { savedCGroups, updateOrCreateUserEntities } from "../user-entity";
import { savedFaceClusters, saveFaceClusters } from "./db";
import {

View File

@ -1,6 +1,6 @@
import { blobCache } from "@/base/blob-cache";
import type { EnteFile } from "@/media/file";
import { ensure } from "@/utils/ensure";
import type { EnteFile } from "../../types/file";
import { fetchRenderableEnteFileBlob } from "./blob";
import { type Box, type FaceIndex } from "./face";
import { clamp } from "./math";

View File

@ -9,7 +9,7 @@
import { assertionFailed } from "@/base/assert";
import type { ElectronMLWorker } from "@/base/types/ipc";
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
import { Matrix } from "ml-matrix";
import { getSimilarityTransformation } from "similarity-transformation";
import type { ImageBitmapAndData } from "./blob";

View File

@ -9,8 +9,8 @@ import log from "@/base/log";
import { masterKeyFromSession } from "@/base/session-store";
import type { Electron } from "@/base/types/ipc";
import { ComlinkWorker } from "@/base/worker/comlink-worker";
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import type { EnteFile } from "@/new/photos/types/file";
import { ensure } from "@/utils/ensure";
import { throttled } from "@/utils/promise";
import { proxy, transfer } from "comlink";

View File

@ -1,6 +1,6 @@
import { decryptBlob } from "@/base/crypto";
import log from "@/base/log";
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
import { nullToUndefined } from "@/utils/transform";
import { z } from "zod";
import { gunzip, gzip } from "../../utils/gzip";

View File

@ -1,6 +1,6 @@
import { assertionFailed } from "@/base/assert";
import log from "@/base/log";
import type { EnteFile } from "../../types/file";
import type { EnteFile } from "@/media/file";
import { getLocalFiles } from "../files";
import { savedCGroups, type CGroup } from "../user-entity";
import type { FaceCluster } from "./cluster";

View File

@ -5,7 +5,7 @@ import { getKVN } from "@/base/kv";
import { ensureAuthToken } from "@/base/local-user";
import log from "@/base/log";
import type { ElectronMLWorker } from "@/base/types/ipc";
import type { EnteFile } from "@/new/photos/types/file";
import type { EnteFile } from "@/media/file";
import { fileLogID } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import { wait } from "@/utils/promise";

View File

@ -5,9 +5,9 @@
import type { Location } from "@/base/types";
import type { Collection } from "@/media/collection";
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import type { Person } from "@/new/photos/services/ml/people";
import type { EnteFile } from "@/new/photos/types/file";
import type { LocationTag } from "../user-entity";
/**

View File

@ -1,8 +1,8 @@
import { HTTPError } from "@/base/http";
import type { Location } from "@/base/types";
import type { Collection } from "@/media/collection";
import type { EnteFile } from "@/media/file";
import { fileCreationPhotoDate, fileLocation } from "@/media/file-metadata";
import type { EnteFile } from "@/new/photos/types/file";
import { ensure } from "@/utils/ensure";
import { nullToUndefined } from "@/utils/transform";
import { getPublicMagicMetadataSync } from "@ente/shared/file-metadata";

View File

@ -1,205 +0,0 @@
import { type Metadata, ItemVisibility } from "@/media/file-metadata";
export interface MetadataFileAttributes {
encryptedData: string;
decryptionHeader: string;
}
export interface S3FileAttributes {
objectKey: string;
decryptionHeader: string;
}
export interface FileInfo {
fileSize: number;
thumbSize: number;
}
export interface MagicMetadataCore<T> {
version: number;
count: number;
header: string;
data: T;
}
export type EncryptedMagicMetadata = MagicMetadataCore<string>;
export interface EncryptedEnteFile {
id: number;
collectionID: number;
ownerID: number;
file: S3FileAttributes;
thumbnail: S3FileAttributes;
metadata: MetadataFileAttributes;
info: FileInfo | undefined;
magicMetadata: EncryptedMagicMetadata;
pubMagicMetadata: EncryptedMagicMetadata;
encryptedKey: string;
keyDecryptionNonce: string;
isDeleted: boolean;
updationTime: number;
}
// TODO: Move into media
export interface EnteFile
extends Omit<
EncryptedEnteFile,
| "metadata"
| "pubMagicMetadata"
| "magicMetadata"
| "encryptedKey"
| "keyDecryptionNonce"
> {
metadata: Metadata;
magicMetadata: FileMagicMetadata;
/**
* The envelope containing the public magic metadata associated with this
* file.
*
* In almost all cases, files will have associated public magic metadata
* since newer clients have something or the other they need to add to it.
* But its presence is not guaranteed.
*/
pubMagicMetadata?: FilePublicMagicMetadata;
isTrashed?: boolean;
/**
* The base64 encoded encryption key associated with this file.
*
* This key is used to encrypt both the file's contents, and any associated
* data (e.g., metadatum, thumbnail) for the file.
*/
key: string;
src?: string;
srcURLs?: SourceURLs;
msrc?: string;
html?: string;
w?: number;
h?: number;
title?: string;
deleteBy?: number;
isSourceLoaded?: boolean;
conversionFailed?: boolean;
isConverted?: boolean;
}
export interface LivePhotoSourceURL {
image: () => Promise<string | undefined>;
video: () => Promise<string | undefined>;
}
export interface LoadedLivePhotoSourceURL {
image: string;
video: string;
}
export interface SourceURLs {
url: string | LivePhotoSourceURL | LoadedLivePhotoSourceURL;
isOriginal: boolean;
isRenderable: boolean;
type: "normal" | "livePhoto";
/**
* Best effort attempt at obtaining the MIME type.
*
* Known cases where it is missing:
*
* - Live photos (these have a different code path for obtaining the URL).
* - A video that is passes the isPlayable test in the browser.
*
*/
mimeType?: string;
}
export interface TrashRequest {
items: TrashRequestItems[];
}
export interface TrashRequestItems {
fileID: number;
collectionID: number;
}
export interface FileWithUpdatedMagicMetadata {
file: EnteFile;
updatedMagicMetadata: FileMagicMetadata;
}
export interface FileWithUpdatedPublicMagicMetadata {
file: EnteFile;
updatedPublicMagicMetadata: FilePublicMagicMetadata;
}
export interface FileMagicMetadataProps {
/**
* The visibility of the file
*
* The file's visibility is user specific attribute, and thus we keep it in
* the private magic metadata. This allows the file's owner to share a file
* and edit its visibility without making revealing their visibility
* preference to the people with whom they have shared the file.
*/
visibility?: ItemVisibility;
filePaths?: string[];
}
export type FileMagicMetadata = MagicMetadataCore<FileMagicMetadataProps>;
export interface FilePublicMagicMetadataProps {
/**
* Modified value of the date time associated with an {@link EnteFile}.
*
* Epoch microseconds.
*/
editedTime?: number;
/**
* Edited name of the {@link EnteFile}.
*
* If the user edits the name of the file within Ente, then the edits are
* saved in this field.
*/
editedName?: string;
/**
* A arbitrary textual caption / description that the user has attached to
* the {@link EnteFile}.
*/
caption?: string;
uploaderName?: string;
/**
* Width of the image / video, in pixels.
*/
w?: number;
/**
* Height of the image / video, in pixels.
*/
h?: number;
/**
* Edited latitude for the {@link EnteFile}.
*
* If the user edits the location (latitude and longitude) of a file within
* Ente, then the edits will be stored as the {@link lat} and {@link long}
* properties in the file's public magic metadata.
*/
lat?: number;
/**
* Edited longitude for the {@link EnteFile}.
*
* See {@link long}.
*/
long?: number;
}
export type FilePublicMagicMetadata =
MagicMetadataCore<FilePublicMagicMetadataProps>;
export interface TrashItem extends Omit<EncryptedTrashItem, "file"> {
file: EnteFile;
}
export interface EncryptedTrashItem {
file: EncryptedEnteFile;
isDeleted: boolean;
isRestored: boolean;
deleteBy: number;
createdAt: number;
updatedAt: number;
}
export type Trash = TrashItem[];

View File

@ -2,9 +2,9 @@ import { isDesktop } from "@/base/app";
import log from "@/base/log";
import { CustomErrorMessage } from "@/base/types/ipc";
import { workerBridge } from "@/base/worker/worker-bridge";
import type { EnteFile } from "@/media/file";
import { needsJPEGConversion } from "@/media/formats";
import { heicToJPEG } from "@/media/heic-convert";
import type { EnteFile } from "../types/file";
import { detectFileTypeInfo } from "./detect-type";
/**

View File

@ -1,9 +1,9 @@
import { isDevBuild } from "@/base/env";
import type { EnteFile } from "@/media/file";
import {
decryptPublicMagicMetadata,
type PublicMagicMetadata,
} from "@/media/file-metadata";
import type { EnteFile } from "@/new/photos/types/file";
import { fileLogID } from "@/new/photos/utils/file";
/**