-
Notifications
You must be signed in to change notification settings - Fork 105
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
Fixed issue with upload directories #5269
Conversation
server/lib/uploader.js
Outdated
if (path.isAbsolute(dir) || dir.startsWith('..')) { | ||
throw new Error(`UPLOAD_DIR (${dir}) must be a relative path within the BHIMA software installation!`); | ||
} | ||
const rootDir = path.normalize(`${process.cwd()}/..`); |
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.
This isn't guaranteed to be the root directory in all circumstances. As explained in this SO answer, the process.cwd()
is wherever the node
call was made. So, it can changed, depending on where the executing terminal is in the file system.
Instead, you probably want __dirname
. Here is a really good tutorial explaining how it works. This will never change, no matter who calls it or from where it is called.
Sorry about the force push 😞 |
Ensures that `__dirname` is passed in as a variable.
Got it working. Thanks so much for your help @jmcameron ! bors r+ |
Build succeeded: |
Fix issue with upload directory always being under the bin directory. Now it obeys the .env setting for UPLOAD_DIR.
NOTES!
TESTING: