Improve how data dirs are treated
This commit is contained in:
parent
b53a4e5bf8
commit
cd280802de
5 changed files with 19 additions and 2 deletions
|
@ -7,6 +7,9 @@ RUN mkdir /app
|
|||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
|
||||
|
||||
|
||||
|
||||
ADD . .
|
||||
|
||||
RUN yarn install --production
|
||||
|
|
|
@ -6,6 +6,11 @@ let accountDb = null;
|
|||
|
||||
function getAccountDb() {
|
||||
if (accountDb == null) {
|
||||
if (!fs.existsSync(config.serverFiles)) {
|
||||
console.log('MAKING SERVER DIR');
|
||||
fs.mkdirSync(config.serverFiles);
|
||||
}
|
||||
|
||||
let dbPath = join(config.serverFiles, 'account.sqlite');
|
||||
let needsInit = !fs.existsSync(dbPath);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ const app = express();
|
|||
app.use(errorMiddleware);
|
||||
|
||||
async function init() {
|
||||
let fileDir = join(__dirname, process.env.ACTUAL_USER_FILES || config.userFiles);
|
||||
let fileDir = join(process.env.ACTUAL_USER_FILES || config.userFiles);
|
||||
|
||||
console.log('Initializing Actual with user file dir:', fileDir);
|
||||
|
||||
|
|
9
app.js
9
app.js
|
@ -1,3 +1,4 @@
|
|||
const fs = require('fs');
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const cors = require('cors');
|
||||
|
@ -31,6 +32,14 @@ app.get('/*', (req, res) => {
|
|||
});
|
||||
|
||||
async function run() {
|
||||
if (!fs.existsSync(config.serverFiles)) {
|
||||
fs.mkdirSync(config.serverFiles);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(config.userFiles)) {
|
||||
fs.mkdirSync(config.userFiles);
|
||||
}
|
||||
|
||||
await accountApp.init();
|
||||
await syncApp.init();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ try {
|
|||
} catch (e) {
|
||||
let fs = require('fs');
|
||||
let { join } = require('path');
|
||||
let root = fs.existsSync('/data') ? '/data' : './';
|
||||
let root = fs.existsSync('/data') ? '/data' : __dirname;
|
||||
|
||||
config = {
|
||||
mode: 'development',
|
||||
|
|
Loading…
Reference in a new issue