separate fileTransfer methods in preparation for backup export

This commit is contained in:
marlon-erler
2026-08-29 00:48:55 +02:00
parent 9ce0db00bc
commit 22fae75a87
+13 -5
View File
@@ -66,10 +66,10 @@ export default class FileTransferModel {
if (this.transferData == undefined) return; if (this.transferData == undefined) return;
if (data.messageBody == undefined) return; if (data.messageBody == undefined) return;
this.handleFile(data.messageBody); this.handleTransferredFile(data.messageBody);
}; };
readonly handleFile = async (encryptedFileData: string): Promise<void> => { readonly handleTransferredFile = async (encryptedFileData: string): Promise<void> => {
if (this.transferData == undefined) return; if (this.transferData == undefined) return;
const decrypted: string = await decryptString( const decrypted: string = await decryptString(
@@ -77,7 +77,11 @@ export default class FileTransferModel {
this.transferData.key, this.transferData.key,
); );
const parsed: any = parse(decrypted); this.handleDecryptedFile(decrypted);
};
readonly handleDecryptedFile = (data: string): void => {
const parsed: any = parse(data);
const isFileData: boolean = checkMatchesObjectStructure( const isFileData: boolean = checkMatchesObjectStructure(
parsed, parsed,
FileDataReference, FileDataReference,
@@ -91,7 +95,7 @@ export default class FileTransferModel {
...fileData.path, ...fileData.path,
); );
this.fileHandlerManager.trigger(pathString); this.fileHandlerManager.trigger(pathString);
}; }
// sending // sending
readonly sendFiles = ( readonly sendFiles = (
@@ -109,7 +113,7 @@ export default class FileTransferModel {
} }
}; };
readonly sendFile = async (filePath: string[]): Promise<void> => { readonly prepareFileForSending = (filePath: string[]): void => {
if (this.transferData == undefined) return; if (this.transferData == undefined) return;
const fileContent: string | null = this.storageModel.read(filePath); const fileContent: string | null = this.storageModel.read(filePath);
if (fileContent == null) return; if (fileContent == null) return;
@@ -119,6 +123,10 @@ export default class FileTransferModel {
body: fileContent, body: fileContent,
}; };
const stringifiedFileData: string = stringify(fileData); const stringifiedFileData: string = stringify(fileData);
this.sendFile(stringifiedFileData);
};
readonly sendFile = async (stringifiedFileData: string): Promise<void> => {
const encryptedFileData: string = await encryptString( const encryptedFileData: string = await encryptString(
stringifiedFileData, stringifiedFileData,
this.transferData.key, this.transferData.key,