-
Notifications
You must be signed in to change notification settings - Fork 115
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
temp folder refactor #5000
temp folder refactor #5000
Conversation
5847164
to
06b200b
Compare
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.
Looks Good. Can you please add --tempFolder
flag in docker-compose file, as an example on how to use it?
storage-node/src/commands/server.ts
Outdated
logger.warn( | ||
'It is recommended to specify a unique file path for temporary files.' + | ||
'For now a temp folder under the uploads folder will be used.' + | ||
'In future this will be warning will become and error!' |
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.
In future this will be warning will become and error!
Can you please rephrase that?
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.
Will rephrase the whole warning to:
You did not specify a path to the temporary directory. A temp folder under the uploads folder will
be used. In a future release passing an absolute path to a temporary directory with the tempFolder argument
will become mandatory.
WDYT?
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.
done in a287fdc
if (flags.logFilePath && path.relative(flags.logFilePath, flags.uploads) === '') { | ||
this.error('Paths for logs and uploads must be unique.') | ||
} |
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.
if (flags.logFilePath && path.relative(flags.logFilePath, flags.uploads) === '') { | |
this.error('Paths for logs and uploads must be unique.') | |
} | |
if (flags.logFilePath && path.relative(flags.logFilePath, flags.uploads) === '..') { | |
this.error('Paths for logs and uploads must be unique.') | |
} |
Shouldn't it be path.relative(flags.logFilePath, flags.uploads) === '..'
, I tested the path.relative
function as path.relative('/uploads/temp', '/uploads')
and I got ..
as return value
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.
Here is was only trying to protect against the two paths being the same location. I was not concerned with temp or logs being subfolders of the main uploads directory. That is why I was comparing with ''
null string.
Originally I was doing if (lags.logFilePath === flags.uploads) { }
but I decided to use path.relative()
to take into account trailing /
path separator..
Given that I added proper filtering of filenames when they are loaded from uploads directory, and if we assume the file names of logs and temp files will not clash with the object id name, perhaps this constraint is not really necessary at all?
if (path.relative(tempFolder, flags.uploads) === '') { | ||
this.error('Paths for temporary and uploads folders must be unique.') |
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.
if (path.relative(tempFolder, flags.uploads) === '') { | |
this.error('Paths for temporary and uploads folders must be unique.') | |
if (path.relative(tempFolder, flags.uploads) === '..') { | |
this.error('Paths for temporary and uploads folders must be unique.') |
Please see the other comment
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.
commented here #5000 (comment)
Added in 3dd8e0a |
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. I believe the version bump and CHANGELOG will be done in separate release PR?
Yes will do that next. |
Fixes #4977