-
Notifications
You must be signed in to change notification settings - Fork 124
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
Upgrade multer #482
Conversation
|
||
const getPackageJsonFromTempDir = require('./get-package-json-from-temp-dir'); | ||
|
||
module.exports = function(files, callback){ | ||
|
||
const packageFile = files[_.keys(files)[0]], | ||
const packageFile = files[0], |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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', '')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
=> filename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
||
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){ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
We use a very old version of multer.