From 49f08b02fae6afdc1b2845ed7c23f60df6759809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Tu=E1=BA=A5n=20D=C5=A9ng?= Date: Mon, 4 Mar 2019 13:25:48 +0700 Subject: [PATCH] Fix unusual bug --- src/core/submit.js | 2 +- src/routes/get.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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