Skip to content

Commit

Permalink
🐛 Fix config for default data dir (#4535)
Browse files Browse the repository at this point in the history
* Fix config for default data dir

* md

* Fix for testing

* linter
  • Loading branch information
lelemm authored Mar 4, 2025
1 parent 47ad149 commit cfc8186
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/sync-server/src/load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const debug = createDebug('actual:config');
const debugSensitive = createDebug('actual-sensitive:config');

const projectRoot = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
const defaultDataDir = fs.existsSync('./data') ? './data' : projectRoot;
const defaultDataDir = process.env.ACTUAL_DATA_DIR
? process.env.ACTUAL_DATA_DIR
: fs.existsSync('/data')
? '/data'
: projectRoot;

debug(`Project root: '${projectRoot}'`);

Expand Down Expand Up @@ -54,7 +58,7 @@ const configSchema = convict({
dataDir: {
doc: 'Default data directory.',
format: String,
default: defaultDataDir,
default: process.env.NODE_ENV === 'test' ? projectRoot : defaultDataDir,
env: 'ACTUAL_DATA_DIR',
},
port: {
Expand All @@ -75,7 +79,7 @@ const configSchema = convict({
default:
process.env.NODE_ENV === 'test'
? path.join(projectRoot, 'test-server-files')
: path.join(projectRoot, 'server-files'),
: path.join(defaultDataDir, 'server-files'),
env: 'ACTUAL_SERVER_FILES',
},
userFiles: {
Expand All @@ -84,7 +88,7 @@ const configSchema = convict({
default:
process.env.NODE_ENV === 'test'
? path.join(projectRoot, 'test-user-files')
: path.join(projectRoot, 'user-files'),
: path.join(defaultDataDir, 'user-files'),
env: 'ACTUAL_USER_FILES',
},
webRoot: {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4535.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [lelemm]
---

Fix config for default data directory

0 comments on commit cfc8186

Please sign in to comment.