From f62f9ec0d59f29999c5b33a5bffea73c71c2e6b2 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 27 May 2023 15:06:15 +0530 Subject: [PATCH 1/3] Remove unnecessary base interface --- apps/photos/src/types/file/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/photos/src/types/file/index.ts b/apps/photos/src/types/file/index.ts index 70dea96a2..9922701b7 100644 --- a/apps/photos/src/types/file/index.ts +++ b/apps/photos/src/types/file/index.ts @@ -5,17 +5,15 @@ import { } from 'types/magicMetadata'; import { Metadata } from 'types/upload'; -interface FileAttributesBase { - decryptionHeader: string; -} - -interface MetadataFileAttributes extends FileAttributesBase { +interface MetadataFileAttributes { encryptedData: string; + decryptionHeader: string; objectKey?: string; } -interface S3FileAttributes extends FileAttributesBase { +interface S3FileAttributes { objectKey: string; encryptedData?: string; + decryptionHeader: string; } export type FileAttributes = MetadataFileAttributes | S3FileAttributes; From b61573eab64a50becbadbf88b802267979a5b860 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 27 May 2023 15:26:31 +0530 Subject: [PATCH 2/3] Remove unnecessary type interface --- apps/photos/src/services/migrateThumbnailService.ts | 6 +++--- apps/photos/src/types/file/index.ts | 12 +++++------- apps/photos/src/types/upload/index.ts | 8 ++++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/photos/src/services/migrateThumbnailService.ts b/apps/photos/src/services/migrateThumbnailService.ts index 5e97cccfb..a5769177a 100644 --- a/apps/photos/src/services/migrateThumbnailService.ts +++ b/apps/photos/src/services/migrateThumbnailService.ts @@ -10,7 +10,7 @@ import { SetProgressTracker } from 'components/FixLargeThumbnail'; import { getFileType } from 'services/typeDetectionService'; import { getLocalTrashedFiles } from './trashService'; import { UploadURL } from 'types/upload'; -import { FileAttributes } from 'types/file'; +import { S3FileAttributes } from 'types/file'; import { USE_CF_PROXY } from 'constants/upload'; import { Remote } from 'comlink'; import { DedicatedCryptoWorker } from 'worker/crypto.worker'; @@ -107,7 +107,7 @@ export async function uploadThumbnail( fileKey: string, updatedThumbnail: Uint8Array, uploadURL: UploadURL -): Promise { +): Promise { const { file: encryptedThumbnail } = await worker.encryptThumbnail( updatedThumbnail, fileKey @@ -134,7 +134,7 @@ export async function uploadThumbnail( export async function updateThumbnail( fileID: number, - newThumbnail: FileAttributes + newThumbnail: S3FileAttributes ) { try { const token = getToken(); diff --git a/apps/photos/src/types/file/index.ts b/apps/photos/src/types/file/index.ts index 9922701b7..0684b4b50 100644 --- a/apps/photos/src/types/file/index.ts +++ b/apps/photos/src/types/file/index.ts @@ -5,19 +5,17 @@ import { } from 'types/magicMetadata'; import { Metadata } from 'types/upload'; -interface MetadataFileAttributes { +export interface MetadataFileAttributes { encryptedData: string; decryptionHeader: string; objectKey?: string; } -interface S3FileAttributes { +export interface S3FileAttributes { objectKey: string; encryptedData?: string; decryptionHeader: string; } -export type FileAttributes = MetadataFileAttributes | S3FileAttributes; - export interface FileInfo { fileSize: number; thumbSize: number; @@ -27,9 +25,9 @@ export interface EncryptedEnteFile { id: number; collectionID: number; ownerID: number; - file: FileAttributes; - thumbnail: FileAttributes; - metadata: FileAttributes; + file: S3FileAttributes; + thumbnail: S3FileAttributes; + metadata: MetadataFileAttributes; info: FileInfo; magicMetadata: EncryptedMagicMetadata; pubMagicMetadata: EncryptedMagicMetadata; diff --git a/apps/photos/src/types/upload/index.ts b/apps/photos/src/types/upload/index.ts index 2a4f71302..edf3b2f6b 100644 --- a/apps/photos/src/types/upload/index.ts +++ b/apps/photos/src/types/upload/index.ts @@ -1,7 +1,7 @@ import { FILE_TYPE } from 'constants/file'; import { Collection } from 'types/collection'; import { B64EncryptionResult, LocalFileAttributes } from 'types/crypto'; -import { FileAttributes } from 'types/file'; +import { MetadataFileAttributes, S3FileAttributes } from 'types/file'; import { EncryptedMagicMetadata, FilePublicMagicMetadata, @@ -122,9 +122,9 @@ export interface ProcessedFile { localID: number; } export interface BackupedFile { - file: FileAttributes; - thumbnail: FileAttributes; - metadata: FileAttributes; + file: S3FileAttributes; + thumbnail: S3FileAttributes; + metadata: MetadataFileAttributes; pubMagicMetadata: EncryptedMagicMetadata; } From fb9d541ad9eaed023bab73b2cc3bb3acdbb14557 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sat, 27 May 2023 15:42:39 +0530 Subject: [PATCH 3/3] Remove extra attributes --- apps/photos/src/types/file/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/photos/src/types/file/index.ts b/apps/photos/src/types/file/index.ts index 0684b4b50..ffcf99587 100644 --- a/apps/photos/src/types/file/index.ts +++ b/apps/photos/src/types/file/index.ts @@ -8,11 +8,9 @@ import { Metadata } from 'types/upload'; export interface MetadataFileAttributes { encryptedData: string; decryptionHeader: string; - objectKey?: string; } export interface S3FileAttributes { objectKey: string; - encryptedData?: string; decryptionHeader: string; }