Page MenuHomePhabricator

D10853.diff
No OneTemporary

D10853.diff

diff --git a/lib/types/media-types.js b/lib/types/media-types.js
--- a/lib/types/media-types.js
+++ b/lib/types/media-types.js
@@ -261,6 +261,38 @@
+exceptionMessage: ?string,
};
+export type DecryptFileMediaMissionStep =
+ | {
+ +step: 'fetch_file',
+ +file: string,
+ +time: number,
+ +success: boolean,
+ +exceptionMessage: ?string,
+ }
+ | {
+ +step: 'decrypt_data',
+ +dataSize: number,
+ +time: number,
+ +isPadded: boolean,
+ +success: boolean,
+ +exceptionMessage: ?string,
+ }
+ | {
+ +step: 'write_file',
+ +file: string,
+ +mimeType: string,
+ +time: number,
+ +success: boolean,
+ +exceptionMessage: ?string,
+ }
+ | {
+ +step: 'create_data_uri',
+ +mimeType: string,
+ +time: number,
+ +success: boolean,
+ +exceptionMessage: ?string,
+ };
+
export type MediaLibrarySelection =
| {
+step: 'photo_library',
@@ -471,6 +503,7 @@
| FetchFileHashMediaMissionStep
| CopyFileMediaMissionStep
| EncryptFileMediaMissionStep
+ | DecryptFileMediaMissionStep
| GetOrientationMediaMissionStep
| GenerateThumbhashMediaMissionStep
| {
@@ -644,7 +677,14 @@
}
| { +success: false, +reason: 'digest_failed' }
| { +success: false, +reason: 'thumbhash_failed' }
- | { +success: false, +reason: 'preload_image_failed' };
+ | { +success: false, +reason: 'preload_image_failed' }
+ | DecryptionFailure;
+
+export type DecryptionFailure = {
+ +success: false,
+ +reason: 'fetch_file_failed' | 'decrypt_data_failed' | 'write_file_failed',
+ +exceptionMessage: ?string,
+};
export type MediaMissionResult = MediaMissionFailure | { +success: true };
diff --git a/native/media/encryption-utils.js b/native/media/encryption-utils.js
--- a/native/media/encryption-utils.js
+++ b/native/media/encryption-utils.js
@@ -13,6 +13,7 @@
import type {
MediaMissionFailure,
MediaMissionStep,
+ DecryptFileMediaMissionStep,
EncryptFileMediaMissionStep,
} from 'lib/types/media-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
@@ -244,48 +245,6 @@
};
}
-type DecryptFileStep =
- | {
- +step: 'fetch_file',
- +file: string,
- +time: number,
- +success: boolean,
- +exceptionMessage: ?string,
- }
- | {
- +step: 'decrypt_data',
- +dataSize: number,
- +time: number,
- +isPadded: boolean,
- +success: boolean,
- +exceptionMessage: ?string,
- }
- | {
- +step: 'write_file',
- +file: string,
- +mimeType: string,
- +time: number,
- +success: boolean,
- +exceptionMessage: ?string,
- }
- | {
- +step: 'create_data_uri',
- +mimeType: string,
- +time: number,
- +success: boolean,
- +exceptionMessage: ?string,
- };
-type DecryptionFailure =
- | MediaMissionFailure
- | {
- +success: false,
- +reason:
- | 'fetch_file_failed'
- | 'decrypt_data_failed'
- | 'write_file_failed',
- +exceptionMessage: ?string,
- };
-
async function decryptMedia(
blobURI: string,
encryptionKey: string,
@@ -294,12 +253,12 @@
+destinationDirectory?: string,
},
): Promise<{
- steps: $ReadOnlyArray<DecryptFileStep>,
- result: DecryptionFailure | { success: true, uri: string },
+ steps: $ReadOnlyArray<DecryptFileMediaMissionStep>,
+ result: MediaMissionFailure | { success: true, uri: string },
}> {
let success = true,
exceptionMessage;
- const steps: DecryptFileStep[] = [];
+ const steps: DecryptFileMediaMissionStep[] = [];
// Step 1. Fetch the file and convert it to a Uint8Array
const fetchStartTime = Date.now();

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 1:03 AM (18 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573359
Default Alt Text
D10853.diff (3 KB)

Event Timeline