New attachment storage system
This commit is contained in:
parent
273e1ccb15
commit
28664a606f
161 changed files with 2418 additions and 1562 deletions
|
@ -2,9 +2,11 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { isFunction, isTypedArray, isUndefined, omit } from 'lodash';
|
||||
import type { AttachmentType } from '../../types/Attachment';
|
||||
import type {
|
||||
AttachmentType,
|
||||
LocalAttachmentV2Type,
|
||||
} from '../../types/Attachment';
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { getPlaintextHashForInMemoryAttachment } from '../../AttachmentCrypto';
|
||||
|
||||
export async function migrateDataToFileSystem(
|
||||
attachment: AttachmentType,
|
||||
|
@ -12,7 +14,9 @@ export async function migrateDataToFileSystem(
|
|||
writeNewAttachmentData,
|
||||
logger,
|
||||
}: {
|
||||
writeNewAttachmentData: (data: Uint8Array) => Promise<string>;
|
||||
writeNewAttachmentData: (
|
||||
data: Uint8Array
|
||||
) => Promise<LocalAttachmentV2Type>;
|
||||
logger: LoggerType;
|
||||
}
|
||||
): Promise<AttachmentType> {
|
||||
|
@ -36,11 +40,8 @@ export async function migrateDataToFileSystem(
|
|||
return omit({ ...attachment }, ['data']);
|
||||
}
|
||||
|
||||
const plaintextHash = getPlaintextHashForInMemoryAttachment(data);
|
||||
const path = await writeNewAttachmentData(data);
|
||||
const local = await writeNewAttachmentData(data);
|
||||
|
||||
const attachmentWithoutData = omit({ ...attachment, path, plaintextHash }, [
|
||||
'data',
|
||||
]);
|
||||
const attachmentWithoutData = omit({ ...attachment, ...local }, ['data']);
|
||||
return attachmentWithoutData;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue