Skip to content

Commit

Permalink
Merge pull request #259 from brown-ccv/fix-file-saving
Browse files Browse the repository at this point in the history
fix: Fix file saving in electron.js
  • Loading branch information
RobertGemmaJr authored Aug 15, 2023
2 parents d7f3b92 + abe7a34 commit 389cea6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
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
Brewfile.lock.json
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);
}
}
});

0 comments on commit 389cea6

Please sign in to comment.