Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix close emoji click button #1992

Merged
merged 3 commits into from
Nov 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make sure the log folder exists before fetching it
Relates #1982
  • Loading branch information
Bilb committed Oct 27, 2021
commit 01392b1c995dfc23c8845db7758255c9a7b6b1d1
14 changes: 8 additions & 6 deletions app/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ let logger;
module.exports = {
initialize,
getLogger,
// for tests only:
isLineAfterDate,
eliminateOutOfDateFiles,
eliminateOldEntries,
fetchLog,
fetch,
};

Expand Down Expand Up @@ -64,6 +59,8 @@ function initialize() {
});

ipc.on('fetch-log', event => {
mkdirp.sync(logPath);

fetch(logPath).then(
data => {
event.sender.send('fetched-log', data);
Expand Down Expand Up @@ -107,7 +104,7 @@ async function deleteAllLogs(logPath) {
async function cleanupLogs(logPath) {
const now = new Date();
const earliestDate = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 3)
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() - 6)
);

try {
Expand Down Expand Up @@ -217,6 +214,11 @@ function fetchLog(logFile) {
}

function fetch(logPath) {
// Check that the file exists locally
if (!fs.existsSync(logPath)) {
console._log('Log folder not found while fetching its content. Quick! Creating it.');
mkdirp.sync(logPath);
}
const files = fs.readdirSync(logPath);
const paths = files.map(file => path.join(logPath, file));

Expand Down