0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 17:32:38 +00:00

Admin script to compress old brews

Also fully delete the text field after compressed version is saved instead of leaving just an empty field.
This commit is contained in:
Trevor Buckner
2020-01-23 09:38:50 -05:00
parent 37eb0d0889
commit bc81e09686
6 changed files with 126 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ HomebrewSchema.statics.get = function(query){
return new Promise((resolve, reject)=>{
Homebrew.find(query, (err, brews)=>{
if(err || !brews.length) return reject('Can not find brew');
if(!_.isUndefined(brews[0].textBin)) { // Uncompress zipped text field
if(!_.isNil(brews[0].textBin)) { // Uncompress zipped text field
unzipped = zlib.inflateRawSync(brews[0].textBin);
brews[0].text = unzipped.toString();
}