mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 05:56:53 +00:00
fa0e6a3eae
The data-directory change said Nest classes inject DataPathsService, but only AdminService did. StorageRegistryService still read the built-in uploads and backups roots and the scratch dir from module constants frozen at import, and StorageJobsService read the scratch dir the same way. The registry now takes DataPathsService through its constructor (a hand-built one resolves the same layout), and the jobs service asks the registry for its temp dir. The plain helper modules keep calling resolveDataPaths() because they run without a container or are shared with code that does: config.ts, the database path, index.ts, the logger, the backup functions and the plugin trees, which the out-of-process supervisor reads too. The app-config README now lists both sides, and the nest README, server/CLAUDE.md and the provider's own comment say the same.
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { resolveDataPaths, type DataPaths } from '../../app-config/data-paths';
|
|
|
|
/**
|
|
* The data layout for Nest classes: the data directory, uploads, backups,
|
|
* scratch space, logs, the key files and the database file.
|
|
*
|
|
* Providers that read a data path take this one (AdminService,
|
|
* StorageRegistryService). Code that runs before the container exists or is
|
|
* shared with code outside it (config.ts key resolution, the database
|
|
* connection, index.ts, the file logger, the backup functions, the plugin
|
|
* trees) calls `resolveDataPaths()` directly; src/app-config/README.md keeps
|
|
* the list. Both get the same answer, and neither counts `..` hops from its
|
|
* own file. Resolved once per built app: none of these move while a process
|
|
* runs.
|
|
*/
|
|
@Injectable()
|
|
export class DataPathsService implements DataPaths {
|
|
readonly dataDir: string;
|
|
readonly uploadsDir: string;
|
|
readonly backupsDir: string;
|
|
readonly tmpDir: string;
|
|
readonly logsDir: string;
|
|
readonly jwtSecretFile: string;
|
|
readonly encryptionKeyFile: string;
|
|
readonly dbFile: string;
|
|
|
|
constructor() {
|
|
const paths = resolveDataPaths();
|
|
this.dataDir = paths.dataDir;
|
|
this.uploadsDir = paths.uploadsDir;
|
|
this.backupsDir = paths.backupsDir;
|
|
this.tmpDir = paths.tmpDir;
|
|
this.logsDir = paths.logsDir;
|
|
this.jwtSecretFile = paths.jwtSecretFile;
|
|
this.encryptionKeyFile = paths.encryptionKeyFile;
|
|
this.dbFile = paths.dbFile;
|
|
}
|
|
}
|