Fix encryption not working after restarting
This commit is contained in:
@@ -260,14 +260,15 @@ class SystemCrypto {
|
||||
* Update .env file with new environment variable
|
||||
*/
|
||||
private async updateEnvFile(key: string, value: string): Promise<void> {
|
||||
// Use persistent config directory if available (Docker), otherwise use current directory
|
||||
const configDir = process.env.NODE_ENV === 'production' &&
|
||||
await fs.access('/app/config').then(() => true).catch(() => false)
|
||||
? '/app/config'
|
||||
: process.cwd();
|
||||
const envPath = path.join(configDir, ".env");
|
||||
// Use data directory for .env file (where database is stored)
|
||||
// This keeps keys and data together in one volume
|
||||
const dataDir = process.env.DATA_DIR || "./db/data";
|
||||
const envPath = path.join(dataDir, ".env");
|
||||
|
||||
try {
|
||||
// Ensure data directory exists
|
||||
await fs.mkdir(dataDir, { recursive: true });
|
||||
|
||||
let envContent = "";
|
||||
|
||||
// Read existing .env file if it exists
|
||||
|
||||
Reference in New Issue
Block a user