Remove LZString compression for data storage

This commit is contained in:
Wu Cheng-Han 2017-01-02 10:59:53 +08:00
parent c904083d1f
commit f6d8e3ab00
5 changed files with 28 additions and 37 deletions

View file

@ -2,7 +2,6 @@
// external modules
var Sequelize = require("sequelize");
var LZString = require('lz-string');
var async = require('async');
var moment = require('moment');
var childProcess = require('child_process');
@ -214,7 +213,7 @@ module.exports = function (sequelize, DataTypes) {
Revision.create({
noteId: note.id,
lastContent: note.content,
length: LZString.decompressFromBase64(note.content).length,
length: note.content.length,
authorship: note.authorship
}).then(function (revision) {
Revision.finishSaveNoteRevision(note, revision, callback);
@ -223,8 +222,8 @@ module.exports = function (sequelize, DataTypes) {
});
} else {
var latestRevision = revisions[0];
var lastContent = LZString.decompressFromBase64(latestRevision.content || latestRevision.lastContent);
var content = LZString.decompressFromBase64(note.content);
var lastContent = latestRevision.content || latestRevision.lastContent;
var content = note.content;
sendDmpWorker({
msg: 'create patch',
lastDoc: lastContent,
@ -244,9 +243,9 @@ module.exports = function (sequelize, DataTypes) {
} else {
Revision.create({
noteId: note.id,
patch: LZString.compressToBase64(patch),
patch: patch,
content: note.content,
length: LZString.decompressFromBase64(note.content).length,
length: note.content.length,
authorship: note.authorship
}).then(function (revision) {
// clear last revision content to reduce db size