Skip to content

Commit

Permalink
Default board, userInfo fix (lovasoa#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie authored and Aleksandr committed Nov 24, 2023
1 parent 2890375 commit dc8d105
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/check_output_directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ async function get_error(directory) {
if (!fs.statSync(directory).isDirectory()) {
error = "exists, but is not a directory";
}
const { uid, gid } = os.userInfo();
const tmpfile = path.join(directory, Math.random() + ".json");
try {
fs.writeFileSync(tmpfile, "{}");
fs.unlinkSync(tmpfile);
} catch (e) {
return (
"does not allow file creation and deletion. " +
"Check the permissions of the directory, and if needed change them so that " +
`user with UID ${uid} has access to them. This can be achieved by running the command: chown ${uid}:${gid} on the directory`
);
let err_msg = "does not allow file creation and deletion. ";
try {
const { uid, gid } = os.userInfo();
err_msg += "Check the permissions of the directory, and if needed change them so that " +
`user with UID ${uid} has access to them. This can be achieved by running the command: chown ${uid}:${gid} on the directory`;
} finally {
return err_msg;
}
}
const fileChecks = [];
const files = await fs.promises.readdir(directory, { withFileTypes: true });
Expand Down
4 changes: 4 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ function handleRequest(request, response) {

case "": // Index page
logRequest(request);
if (config.DEFAULT_BOARD) {
response.writeHead(302, { Location: 'boards/' + encodeURIComponent(config.DEFAULT_BOARD) });
response.end(name);
} else
indexTemplate.serve(request, response);
break;

Expand Down

0 comments on commit dc8d105

Please sign in to comment.