0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-21 00:42:48 +00:00

Make brand new files also save compressed

This commit is contained in:
Trevor Buckner
2020-01-10 15:55:21 -05:00
parent 1ff3f96f6c
commit 8adc04a565

View File

@@ -32,9 +32,14 @@ router.post('/api', (req, res)=>{
req.body,
{ authors: authors }
));
if(!newHomebrew.title){
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)=>{
if(err){
console.error(err, err.toString(), err.stack);