Skip to content

Commit

Permalink
feat: save reports to user directories
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 24, 2020
1 parent e0e4739 commit 783214e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scrap-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,15 @@ module.exports = async (baseUrl, options = {}) => {
}

// copy to local reports
const localPath = 'data/reports/' + jsonName;
let localDir = 'data/reports/';
if (options.socket.uid) {
const userDir = options.socket.uid.slice(0, 5);
localDir += userDir + '/';
if (!fs.existsSync(localDir)) fs.mkdirSync(localDir);
}
const localPath = localDir + jsonName;
fs.copyFileSync(jsonPath, localPath);

socketSend(options.socket, 'result', {name: jsonName});

// TODO: error upload 8MB+
Expand Down
4 changes: 4 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ io.on("connection", (socket) => {
? "anonymous user"
: "user authenticated";
log(msg, socket);

sendStats(socket);
});

socket.on("scan", async ({ url, args }) => {
Expand All @@ -115,9 +117,11 @@ io.on("connection", (socket) => {
opts.webService = true;
opts.socket = socket;

// console.log('opts: ', opts);
program.outBrief(opts);

// try {
log('Pending...', socket)
q.push(async function () {
return await scan(url, opts);
});
Expand Down

0 comments on commit 783214e

Please sign in to comment.