Exclude unnecessary data in export: profiles, replayable errors
This commit is contained in:
parent
c0c758d459
commit
153a22f46b
1 changed files with 20 additions and 1 deletions
|
@ -165,7 +165,14 @@ function exportToJsonFile(db, fileWriter) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
stream.write(',');
|
stream.write(',');
|
||||||
}
|
}
|
||||||
const jsonString = JSON.stringify(stringify(cursor.value));
|
|
||||||
|
// Preventing base64'd images from reaching the disk, making db.json too big
|
||||||
|
const item = _.omit(
|
||||||
|
cursor.value,
|
||||||
|
['avatar', 'profileAvatar']
|
||||||
|
);
|
||||||
|
|
||||||
|
const jsonString = JSON.stringify(stringify(item));
|
||||||
stream.write(jsonString);
|
stream.write(jsonString);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -511,10 +518,22 @@ async function exportConversation(db, name, conversation, dir) {
|
||||||
stream.write(',');
|
stream.write(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eliminate attachment data from the JSON, since it will go to disk
|
||||||
message.attachments = _.map(
|
message.attachments = _.map(
|
||||||
attachments,
|
attachments,
|
||||||
attachment => _.omit(attachment, ['data'])
|
attachment => _.omit(attachment, ['data'])
|
||||||
);
|
);
|
||||||
|
// completely drop any attachments in messages cached in error objects
|
||||||
|
// TODO: move to lodash. Sadly, a number of the method signatures have changed!
|
||||||
|
message.errors = _.map(message.errors, (error) => {
|
||||||
|
if (error && error.args) {
|
||||||
|
error.args = [];
|
||||||
|
}
|
||||||
|
if (error && error.stack) {
|
||||||
|
error.stack = '';
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
});
|
||||||
|
|
||||||
const jsonString = JSON.stringify(stringify(message));
|
const jsonString = JSON.stringify(stringify(message));
|
||||||
stream.write(jsonString);
|
stream.write(jsonString);
|
||||||
|
|
Loading…
Add table
Reference in a new issue