fix: multiple bug fixes
isolated users, db backup, weird disconnect issues for long voice sessions,
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
const PACKAGED_DATA_DIRECTORY_NAME = 'MetoYou Server';
|
||||
|
||||
type PackagedProcess = NodeJS.Process & { pkg?: unknown };
|
||||
|
||||
function uniquePaths(paths: string[]): string[] {
|
||||
@@ -21,6 +24,33 @@ export function resolveRuntimePath(...segments: string[]): string {
|
||||
return path.join(getRuntimeBaseDir(), ...segments);
|
||||
}
|
||||
|
||||
function resolvePackagedDataDirectory(): string {
|
||||
const homeDirectory = os.homedir();
|
||||
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
return path.join(
|
||||
process.env.APPDATA || path.join(homeDirectory, 'AppData', 'Roaming'),
|
||||
PACKAGED_DATA_DIRECTORY_NAME
|
||||
);
|
||||
case 'darwin':
|
||||
return path.join(homeDirectory, 'Library', 'Application Support', PACKAGED_DATA_DIRECTORY_NAME);
|
||||
default:
|
||||
return path.join(
|
||||
process.env.XDG_DATA_HOME || path.join(homeDirectory, '.local', 'share'),
|
||||
PACKAGED_DATA_DIRECTORY_NAME
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function resolvePersistentDataPath(...segments: string[]): string {
|
||||
if (!isPackagedRuntime()) {
|
||||
return resolveRuntimePath(...segments);
|
||||
}
|
||||
|
||||
return path.join(resolvePackagedDataDirectory(), ...segments);
|
||||
}
|
||||
|
||||
export function resolveProjectRootPath(...segments: string[]): string {
|
||||
return path.resolve(__dirname, '..', '..', ...segments);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user