Respect configuration for user-files

This commit is contained in:
James Long 2022-09-15 10:16:20 -04:00
parent 3c602268e3
commit 8aeb815b5a
3 changed files with 7 additions and 12 deletions

View file

@ -16,17 +16,8 @@ let SyncPb = actual.internal.SyncProtoBuf;
const app = express();
app.use(errorMiddleware);
async function init() {
let fileDir = join(process.env.ACTUAL_USER_FILES || config.userFiles);
console.log('Initializing Actual with user file dir:', fileDir);
await actual.init({
config: {
dataDir: fileDir
}
});
}
// eslint-disable-next-line
async function init() {}
// This is a version representing the internal format of sync
// messages. When this changes, all sync files need to be reset. We

View file

@ -16,4 +16,7 @@ try {
};
}
// The env variable always takes precedence
config.userFiles = process.env.ACTUAL_USER_FILES || config.userFiles;
module.exports = config;

View file

@ -1,6 +1,7 @@
let { existsSync, readFileSync } = require('fs');
let { join } = require('path');
let { openDatabase } = require('./db');
let config = require('./load-config');
let actual = require('@actual-app/api');
let merkle = actual.internal.merkle;
@ -8,7 +9,7 @@ let SyncPb = actual.internal.SyncProtoBuf;
let Timestamp = actual.internal.timestamp.default;
function getGroupDb(groupId) {
let path = join(__dirname, `user-files/${groupId}.sqlite`);
let path = join(config.userFiles, `${groupId}.sqlite`);
let needsInit = !existsSync(path);
let db = openDatabase(path);