0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 22:52:40 +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,
{ 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);