prevent errors with corrupt files

This commit is contained in:
marlon-erler
2024-07-22 00:52:54 +02:00
parent 168c13118d
commit 3f48f26327
4 changed files with 58 additions and 34 deletions
+12 -2
View File
@@ -444,6 +444,7 @@
handleStringifiedFile = (stringifiedFile) => {
const file = parseValidObject(stringifiedFile);
if (file == null) return;
this.storeFile(file);
};
// methods
addFile = (file) => {
@@ -461,6 +462,8 @@
file,
fileContentName
);
const existingFileContent = this.storageModel.read(fileContentPath);
if (existingFileContent != null) return;
const stringifiedContent = stringify(fileContent);
this.storageModel.write(fileContentPath, stringifiedContent);
};
@@ -500,6 +503,13 @@
const filePath = _FileModel.getFilePath(file.id);
return [...filePath, fileContentName];
};
static createFile = () => {
return {
dataVersion: DATA_VERSION,
id: v4_default(),
contentVersions: []
};
};
};
// src/Model/Utility/crypto.ts
@@ -757,7 +767,7 @@
// utility
static generateChatInfo = (primaryChannel) => {
return {
dataVersion: "v2",
dataVersion: DATA_VERSION,
primaryChannel,
secondaryChannels: [],
encryptionKey: "",
@@ -766,7 +776,7 @@
};
static createChatMessage = async (channel, sender, encryptionKey, body, file) => {
const chatMessage = {
dataVersion: "v2",
dataVersion: DATA_VERSION,
id: v4_default(),
channel,
sender,