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:
1 parent
37eb0d0889
commit
bc81e09686
6 files changed
+126
-4
No files matched your search
@@ -38,7 +38,7 @@ router.post('/api', (req, res)=>{
|
||||
}
|
||||
|
||||
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.text = undefined; // Delete the non-binary text field since it's not needed anymore
|
||||
|
||||
newHomebrew.save((err, obj)=>{
|
||||
if(err){
|
||||
@@ -54,7 +54,7 @@ router.put('/api/update/:id', (req, res)=>{
|
||||
.then((brew)=>{
|
||||
brew = _.merge(brew, req.body);
|
||||
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.text = undefined; // Clear out the non-binary text field so its not saved twice
|
||||
brew.updatedAt = new Date();
|
||||
|
||||
if(req.account) brew.authors = _.uniq(_.concat(brew.authors, req.account.username));
|
||||
|
||||
Reference in new issue
Block a user