Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade multer #482

Merged
merged 1 commit into from
May 11, 2017
Merged

Upgrade multer #482

merged 1 commit into from
May 11, 2017

Conversation

matteofigus
Copy link
Member

We use a very old version of multer.


const getPackageJsonFromTempDir = require('./get-package-json-from-temp-dir');

module.exports = function(files, callback){

const packageFile = files[_.keys(files)[0]],
const packageFile = files[0],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of object, req.files now returns an array


if(file.mimetype !== 'application/octet-stream' || !!file.truncated || file.extension !== 'gz' || file.path.indexOf('.tar.gz') < 0){
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.extension is deprecated and file.filename already has the extension check

dest: res.conf.tempDir,
fieldSize: 10,
rename: function(fieldname, filename){
return format('{0}-{1}.tar', filename.replace('.tar', '').replace(/\W+/g, '-').toLowerCase(), Date.now());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old filename replacement didn't take in consideration the extension (.gz).
The new mechanism has the whole filename so that's why it's slightly different.

}
}, (err, res) => {
extractPackage([{
filename: '1478279453422.tar.gz',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name => filename

packagePath = path.resolve(packageFile.path),
packageUntarOutput = path.resolve(packageFile.path, '..', packageFile.name.replace('.tar.gz', '')),
packageUntarOutput = path.resolve(packageFile.path, '..', packageFile.filename.replace('.tar.gz', '')),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name => filename

Copy link
Contributor

@nickbalestra nickbalestra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@nickbalestra nickbalestra merged commit 6eecdc0 into master May 11, 2017
@nickbalestra nickbalestra deleted the multer branch May 11, 2017 14:27

if(file.mimetype !== 'application/octet-stream' || !!file.truncated || file.extension !== 'gz' || file.path.indexOf('.tar.gz') < 0){
if(file.mimetype !== 'application/octet-stream' || file.truncated || file.filename.indexOf('.tar.gz') < 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor but for readability purpose what about start to use contains instead? I know we are still targeting node 4. But just as a reminder 😊

// cc @matteofigus @nickbalestra

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Perhaps we can switch to lodash's contains in a separate PR using this: https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/prefer-includes.md

And then move to ES6's when deprecating node 4?

Copy link
Contributor

@nickbalestra nickbalestra May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on lodash's contains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants