Fix: prevent duplication of ROOT_DIR in file system storage initialization

- Added a check to avoid appending `ROOT_DIR` if the `rootDir` already ends with it.
- Ensures proper directory paths setup without redundant path segments.
This commit is contained in:
David Snelling 2025-07-18 10:59:14 -07:00
parent e7dcedae60
commit 3fe2a6e7f0

View file

@ -111,7 +111,14 @@ export class FileSystemStorage implements StorageAdapter {
try {
// Now set up the directory paths
const rootDir = this.rootDir || process.cwd()
this.rootDir = path.resolve(rootDir, ROOT_DIR)
// Check if rootDir already ends with ROOT_DIR to prevent duplication
if (rootDir.endsWith(ROOT_DIR)) {
this.rootDir = rootDir
} else {
this.rootDir = path.resolve(rootDir, ROOT_DIR)
}
this.nounsDir = path.join(this.rootDir, NOUNS_DIR)
this.verbsDir = path.join(this.rootDir, VERBS_DIR)
this.metadataDir = path.join(this.rootDir, METADATA_DIR)