Skip to content

Commit

Permalink
change db folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Nov 21, 2024
1 parent d918fd7 commit c1ddced
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ if (process.env.NODE_ENV === 'development') {
app.commandLine.appendSwitch('v', '1');
}

// Disable hardware acceleration
// NOTE: I had a toggle setting for this but the config file was causing errors in Sentry
// Disabling hardware acceleration seems to make the collapsable animations in the POS screen work better
// app.disableHardwareAcceleration();

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
Expand Down
3 changes: 2 additions & 1 deletion src/main/clear-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const clearAppDataDialog = () => {
const dbFolder =
process.env.NODE_ENV === 'development'
? path.resolve('databases')
: path.resolve(app.getPath('userData'), 'databases');
: path.resolve(app.getPath('userData'), 'wcpos_dbs');

dialog
.showMessageBox({
Expand All @@ -33,6 +33,7 @@ export const clearAppDataDialog = () => {
closeAll();
return fs.remove(dbFolder).then(() => {
// setTimeout(() => ipcRenderer.send('forward-message', 'hard-reload'), 1000);
logger.info(t('Cleared app data', { _tags: 'electron' }));
app.relaunch();
app.quit();
});
Expand Down
14 changes: 4 additions & 10 deletions src/main/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ const openDatabase = (name: string) => {
try {
/**
* Determine database folder
*
* @NOTE - there seems to be a weird conflict with electron-store if I use the name 'databases'
* in the app's userData folder - it was deleting the directory every time the app started ??!!
*/
const dbFolder = isDevelopment
? path.resolve('databases')
: path.resolve(app.getPath('userData'), 'databases');
: path.resolve(app.getPath('userData'), 'wcpos_dbs');

/**
* Create folder if it doesn't exist
Expand All @@ -45,15 +48,6 @@ const openDatabase = (name: string) => {
}
}

/**
* Watch for folder deletion or renaming
*/
fs.watch(path.dirname(dbFolder), (eventType, filename) => {
if (filename === path.basename(dbFolder) && eventType === 'rename') {
logger.warn('Databases folder was removed or renamed.');
}
});

/**
* Open database
*/
Expand Down

0 comments on commit c1ddced

Please sign in to comment.