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: Fix file saving in electron.js #259

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Dependencies
/node_modules
Brewfile.lock.json
/.pnp
.pnp.js

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"electron-squirrel-startup": "^1.0.0",
"event-marker": "git+https://github.com/brown-ccv/event-marker.git",
"execa": "^5.0.0",
"firebase": "^9.8.4",
"firebase": "^10.1.0",
"fs-extra": "^8.1.0",
"jquery": "^3.4.1",
"jspsych": "^7.2.3",
Expand All @@ -50,10 +50,10 @@
"dotenv-cli": "^7.0.0",
"electron": "19.0.8",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"firebase-admin": "^11.0.1",
"firebase-tools": "^11.0.1",
"firebase-tools": "^12.4.7",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"require-context.macro": "^1.1.1",
Expand All @@ -75,7 +75,7 @@
"start": "cross-env BROWSER=\"none\" NODE_PATH=\"./src\" IMAGE_INLINE_SIZE_LIMIT=0 react-scripts start",
"start:browser": "cross-env IMAGE_INLINE_SIZE_LIMIT=0 react-scripts start",
"electron": "electron .",
"electron-dev": "wait-on http://localhost:3000 && cross-env ELECTRON_START_URL=\"http://localhost:3000\" electron .",
"electron-dev": "wait-on http://127.0.0.1:3000 && cross-env ELECTRON_START_URL=\"http://127.0.0.1:3000\" electron .",
"dev": "concurrently -k npm:start npm:electron-dev",
"dev:firebase": "dotenv -e env/.env.firebase npm run start:browser",
"dev:home": "dotenv -e env/.env.home npm run dev",
Expand Down
13 changes: 9 additions & 4 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,14 @@ app.on('will-quit', () => {
stream = false;

// copy file to config location
fs.mkdir(savePath, { recursive: true }, (err) => {
log.error(err);
fs.copyFileSync(preSavePath, getFullPath(`pid_${participantID}_${today.getTime()}.json`));
});
const fullPath = getFullPath(`pid_${participantID}_${today.getTime()}.json`);
try {
fs.mkdirSync(savePath, { recursive: true });
fs.copyFileSync(preSavePath, fullPath);
} catch (e) {
console.error('Unable to save file: ', fullPath);
console.error(e);
log.error(e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does log.error do that console.error doesn't? might need to add to my toolbelt!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a special logging tool needed by electron. https://www.npmjs.com/package/electron-log

}
}
});
Loading