Skip to content

Commit

Permalink
Ensure the user data directory exists before creating the process dir…
Browse files Browse the repository at this point in the history
…ectory (#1054)

* Ensure the user data directory exists before creating the process directory

* Adding a release note
  • Loading branch information
kraenhansen committed Dec 21, 2018
1 parent 83fe4bf commit 49c16e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This version of Studio changes how Realm state and file size metrics (displayed

## Fixed
- Fixed displaying Realm state and file size in the server administration window. ([#1027](https://github.com/realm/realm-studio/pull/1027))
- Fixed process directory creation on initial startup. ([#1053](https://github.com/realm/realm-studio/pull/1053), since v3.1.2)

## Internals
- None
14 changes: 11 additions & 3 deletions src/utils/process-directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ const app = electron.app || electron.remote.app;
const userDataPath = app.getPath('userData');
const rendererPattern = /^renderer-.+$/;

function changeProcessDirectory(relativePath: string) {
const path = resolve(userDataPath, relativePath);
// Remove the directory if it already exists
function ensureDirectory(path: string) {
// If the directory does not exist
if (!fs.existsSync(path)) {
// Create the directory
fs.mkdirSync(path);
}
}

function changeProcessDirectory(relativePath: string) {
// Ensure the usersdata directory exists
ensureDirectory(userDataPath);
// Compute the process directory path
const path = resolve(userDataPath, relativePath);
// Ensure the path exists
ensureDirectory(path);
// Change to it
process.chdir(path);
}
Expand Down

0 comments on commit 49c16e4

Please sign in to comment.