From fccf0537ddb96522ba4e8355c0acf6bfbaa0a1f5 Mon Sep 17 00:00:00 2001 From: Danilo Prates Date: Mon, 17 Sep 2018 11:00:40 -0300 Subject: [PATCH 1/7] [DDW-413] Allowed files logic --- source/main/config.js | 7 ++++++ source/main/ipc-api/get-logs.js | 42 +++++++++++---------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/source/main/config.js b/source/main/config.js index bf49027ef6..575d8fdcb2 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -6,3 +6,10 @@ export const APP_NAME = 'Daedalus'; export const runtimeFolderPath = getRuntimeFolderPath(process.platform, process.env, APP_NAME); export const appLogsFolderPath = launcherConfig.logsPrefix || path.join(runtimeFolderPath, 'Logs'); export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub'); + +export const ALLOWED_LOGS = [ + 'Daedalus.log', + 'launcher', +]; +export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)([0-9]{14})/); +export const MAX_NODE_LOGS_ALLOWED = 3; diff --git a/source/main/ipc-api/get-logs.js b/source/main/ipc-api/get-logs.js index 359aabea18..fda806da69 100644 --- a/source/main/ipc-api/get-logs.js +++ b/source/main/ipc-api/get-logs.js @@ -3,34 +3,17 @@ import { ipcMain } from 'electron'; import { includes, sortBy } from 'lodash'; import fs from 'fs'; import path from 'path'; -import { pubLogsFolderPath } from '../config'; +import { + pubLogsFolderPath, + MAX_NODE_LOGS_ALLOWED, + ALLOWED_LOGS, + ALLOWED_NODE_LOGS, +} from '../config'; import { GET_LOGS } from '../../common/ipc-api'; -const ALLOWED_LOGS = [ - 'Daedalus.log', - 'launcher', - 'node.pub', - 'node.pub.0', - 'node.pub.1', - 'node.pub.2', - 'node.pub.3', - 'node.pub.4', - 'node.pub.5', - 'node.pub.6', - 'node.pub.7', - 'node.pub.8', - 'node.pub.9', - 'node.pub.10', - 'node.pub.11', - 'node.pub.12', - 'node.pub.13', - 'node.pub.14', - 'node.pub.15', - 'node.pub.16', - 'node.pub.17', - 'node.pub.18', - 'node.pub.19', -]; +const isFileAllowed = (fileName: string) => includes(ALLOWED_LOGS, fileName); +const isFileNodeLog = (fileName: string, nodeLogsIncluded: number) => + ALLOWED_NODE_LOGS.test(fileName) && nodeLogsIncluded < MAX_NODE_LOGS_ALLOWED; export default () => { ipcMain.on(GET_LOGS.REQUEST, (event) => { @@ -40,13 +23,16 @@ export default () => { const logFiles = []; if (fs.existsSync(pubLogsFolderPath)) { const files = fs.readdirSync(pubLogsFolderPath); + let nodeLogsIncluded = 0; for (let i = 0; i < files.length; i++) { const currentFile = path.join(pubLogsFolderPath, files[i]); if (fs.statSync(currentFile).isFile()) { const fileName = path.basename(currentFile); - const isFileAllowed = includes(ALLOWED_LOGS, fileName); - if (isFileAllowed) { + if (isFileAllowed(fileName)) { logFiles.push(fileName); + } else if (isFileNodeLog(fileName, nodeLogsIncluded)) { + logFiles.push(fileName); + nodeLogsIncluded++; } } } From c7afaa7c58a7b91e5abe1ace0f5784e812dea4f6 Mon Sep 17 00:00:00 2001 From: Danilo Prates Date: Wed, 19 Sep 2018 16:26:25 -0300 Subject: [PATCH 2/7] [DDW-413] Sorting the logs list --- source/main/ipc-api/get-logs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/main/ipc-api/get-logs.js b/source/main/ipc-api/get-logs.js index fda806da69..cd7440cc4e 100644 --- a/source/main/ipc-api/get-logs.js +++ b/source/main/ipc-api/get-logs.js @@ -22,7 +22,11 @@ export default () => { // check if pub folder exists and create array of log file names const logFiles = []; if (fs.existsSync(pubLogsFolderPath)) { - const files = fs.readdirSync(pubLogsFolderPath); + + const files = fs + .readdirSync(pubLogsFolderPath) + .sort(); + let nodeLogsIncluded = 0; for (let i = 0; i < files.length; i++) { const currentFile = path.join(pubLogsFolderPath, files[i]); From 2c0fbece7712dda0815dc2c8e6998dc04a835222 Mon Sep 17 00:00:00 2001 From: Danilo Prates Date: Fri, 21 Sep 2018 09:23:46 -0300 Subject: [PATCH 3/7] [DDW-413] Correct regex for the public node logs --- source/main/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/main/config.js b/source/main/config.js index 575d8fdcb2..291ea3b0b7 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -11,5 +11,5 @@ export const ALLOWED_LOGS = [ 'Daedalus.log', 'launcher', ]; -export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)([0-9]{14})/); +export const ALLOWED_NODE_LOGS = new RegExp(/(node.pub-)([0-9]{14})/); export const MAX_NODE_LOGS_ALLOWED = 3; From 0239b06c3ddfa7b25619174c0ecfc9aff79216e3 Mon Sep 17 00:00:00 2001 From: Danilo Prates Date: Fri, 21 Sep 2018 12:08:24 -0300 Subject: [PATCH 4/7] [DDW-413] Gets the most fresh node logs --- source/main/ipc-api/get-logs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/main/ipc-api/get-logs.js b/source/main/ipc-api/get-logs.js index cd7440cc4e..fbf98f3afc 100644 --- a/source/main/ipc-api/get-logs.js +++ b/source/main/ipc-api/get-logs.js @@ -25,7 +25,8 @@ export default () => { const files = fs .readdirSync(pubLogsFolderPath) - .sort(); + .sort() + .reverse(); let nodeLogsIncluded = 0; for (let i = 0; i < files.length; i++) { From d8ce8a95eaefbe68c4f99f1d800c639b0c5f66c7 Mon Sep 17 00:00:00 2001 From: Danilo Prates Date: Mon, 24 Sep 2018 16:59:18 -0300 Subject: [PATCH 5/7] [DDW-413] Includes 'launcher-{TIMESTAMP}' logs and improves regex logic --- source/main/config.js | 5 +++-- source/main/ipc-api/get-logs.js | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/main/config.js b/source/main/config.js index 291ea3b0b7..284f3b61e1 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -9,7 +9,8 @@ export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub'); export const ALLOWED_LOGS = [ 'Daedalus.log', - 'launcher', ]; -export const ALLOWED_NODE_LOGS = new RegExp(/(node.pub-)([0-9]{14})/); +export const ALLOWED_NODE_LOGS = new RegExp(/(node.pub-)(\d{14}$)/); +export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/); export const MAX_NODE_LOGS_ALLOWED = 3; +export const MAX_LAUNCHER_LOGS_ALLOWED = 3; diff --git a/source/main/ipc-api/get-logs.js b/source/main/ipc-api/get-logs.js index fbf98f3afc..a0a53958d0 100644 --- a/source/main/ipc-api/get-logs.js +++ b/source/main/ipc-api/get-logs.js @@ -8,12 +8,17 @@ import { MAX_NODE_LOGS_ALLOWED, ALLOWED_LOGS, ALLOWED_NODE_LOGS, + ALLOWED_LAUNCHER_LOGS, + MAX_LAUNCHER_LOGS_ALLOWED, } from '../config'; import { GET_LOGS } from '../../common/ipc-api'; const isFileAllowed = (fileName: string) => includes(ALLOWED_LOGS, fileName); const isFileNodeLog = (fileName: string, nodeLogsIncluded: number) => ALLOWED_NODE_LOGS.test(fileName) && nodeLogsIncluded < MAX_NODE_LOGS_ALLOWED; +const isFileLauncherLog = (fileName: string, nodeLogsIncluded: number) => + ALLOWED_LAUNCHER_LOGS.test(fileName) && nodeLogsIncluded < MAX_LAUNCHER_LOGS_ALLOWED; + export default () => { ipcMain.on(GET_LOGS.REQUEST, (event) => { @@ -29,6 +34,7 @@ export default () => { .reverse(); let nodeLogsIncluded = 0; + let launcherLogsIncluded = 0; for (let i = 0; i < files.length; i++) { const currentFile = path.join(pubLogsFolderPath, files[i]); if (fs.statSync(currentFile).isFile()) { @@ -38,6 +44,9 @@ export default () => { } else if (isFileNodeLog(fileName, nodeLogsIncluded)) { logFiles.push(fileName); nodeLogsIncluded++; + } else if (isFileLauncherLog(fileName, launcherLogsIncluded)) { + logFiles.push(fileName); + launcherLogsIncluded++; } } } From bc21151f9aabece9bb3eb1d9d697986c1d5fba4e Mon Sep 17 00:00:00 2001 From: nikolaglumac Date: Thu, 27 Sep 2018 09:51:29 +0200 Subject: [PATCH 6/7] [DDW-413] Bump Cardano version to the tip of develop branch --- cardano-sl-src.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cardano-sl-src.json b/cardano-sl-src.json index 2267f46ffb..adedd9dbff 100644 --- a/cardano-sl-src.json +++ b/cardano-sl-src.json @@ -1,6 +1,6 @@ { "url": "https://github.com/input-output-hk/cardano-sl", - "rev": "515afc3fb6e8b9804a6c325defa95a778df8c8e8", - "sha256": "0f7djx171jvcp1wxnpy063xnqh28qhl701n9ldsy4bj89bj2iza2", + "rev": "d45e8dfbddde0d4a93a409680ddf9ef68e97e784", + "sha256": "1rpczahvpxv1rvc19g89jsyw8zb7k8n15bxb3h00h9v813szfq00", "fetchSubmodules": false } From dee18b13ceac7f7e115a356930cdbc5da5380ea9 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 1 Oct 2018 17:02:03 -0300 Subject: [PATCH 7/7] [DDW-413] correct regex - node log name pattern --- source/main/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/main/config.js b/source/main/config.js index 284f3b61e1..c328b6a52c 100644 --- a/source/main/config.js +++ b/source/main/config.js @@ -10,7 +10,7 @@ export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub'); export const ALLOWED_LOGS = [ 'Daedalus.log', ]; -export const ALLOWED_NODE_LOGS = new RegExp(/(node.pub-)(\d{14}$)/); +export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)(\d{14}$)/); export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/); export const MAX_NODE_LOGS_ALLOWED = 3; export const MAX_LAUNCHER_LOGS_ALLOWED = 3;