diff --git a/src/core/submit.js b/src/core/submit.js index 282dc83..964c56f 100644 --- a/src/core/submit.js +++ b/src/core/submit.js @@ -16,7 +16,7 @@ async function submitToThemis(code, id) { const newName = `[${id}][${base}]${ext}`; const dest = join(submitFolder, newName); - copyFile(code.path, dest, (err) => { + return copyFile(code.path, dest, (err) => { if (err) throw err; }); } diff --git a/src/routes/get.js b/src/routes/get.js index 10ba12e..2af0a15 100644 --- a/src/routes/get.js +++ b/src/routes/get.js @@ -2,7 +2,7 @@ const express = require("express"); const { join } = require("path"); -const { readdirSync } = require("fs"); +const { readdirSync, mkdirSync, existsSync } = require("fs"); const { submitFolder, cwd } = require("../config/folder"); const { parseLog, isFile } = require("../util/parser"); @@ -20,6 +20,7 @@ router.get("/", (req, res) => { // TOOO: Seperate session to make the log private // Folder contain log const logFolder = join(cwd, submitFolder, "Logs"); + if (!existsSync(logFolder)) mkdirSync(logFolder); const fileList = readdirSync(logFolder) .map((file) => join(logFolder, file)) // Convert into fullpath