0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 14:52:38 +00:00

Make brand new files also save compressed

This commit is contained in:
Trevor Buckner
2020-01-10 16:03:04 -05:00
committed by GitHub
parent 486841084f
commit 81c361bfb8

View File

@@ -32,9 +32,14 @@ router.post('/api', (req, res)=>{
req.body, req.body,
{ authors: authors } { authors: authors }
)); ));
if(!newHomebrew.title){ if(!newHomebrew.title){
newHomebrew.title = getGoodBrewTitle(newHomebrew.text); newHomebrew.title = getGoodBrewTitle(newHomebrew.text);
} }
newHomebrew.textBin = zlib.deflateRawSync(newHomebrew.text); // Compress brew text to binary before saving
newHomebrew.text = ''; // Clear out the non-binary text field so its not saved twice
newHomebrew.save((err, obj)=>{ newHomebrew.save((err, obj)=>{
if(err){ if(err){
console.error(err, err.toString(), err.stack); console.error(err, err.toString(), err.stack);