mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 16:22:44 +00:00
Make compression raw (no wrapper). Otherwise small files are actually larger after compression.
This commit is contained in:
@@ -48,7 +48,7 @@ router.put('/api/update/:id', (req, res)=>{
|
||||
HomebrewModel.get({ editId: req.params.id })
|
||||
.then((brew)=>{
|
||||
brew = _.merge(brew, req.body);
|
||||
brew.textBin = zlib.deflateSync(req.body.text); // Compress brew text to binary before saving
|
||||
brew.textBin = zlib.deflateRawSync(req.body.text); // Compress brew text to binary before saving
|
||||
brew.text = ''; // Clear out the non-binary text field so its not saved twice
|
||||
brew.updatedAt = new Date();
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ HomebrewSchema.statics.get = function(query){
|
||||
Homebrew.find(query, (err, brews)=>{
|
||||
if(err || !brews.length) return reject('Can not find brew');
|
||||
if(!_.isUndefined(brews[0].textBin)) { // Uncompress zipped text field
|
||||
unzipped = zlib.unzipSync(brews[0].textBin);
|
||||
unzipped = zlib.inflateRawSync(brews[0].textBin);
|
||||
brews[0].text = unzipped.toString();
|
||||
}
|
||||
return resolve(brews[0]);
|
||||
|
||||
Reference in New Issue
Block a user