From 3fe2a6e7f0eafb45b0c611c9c90560b705dfb2e4 Mon Sep 17 00:00:00 2001 From: dpsifr Date: Fri, 18 Jul 2025 10:59:14 -0700 Subject: [PATCH] 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. --- src/storage/fileSystemStorage.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/storage/fileSystemStorage.ts b/src/storage/fileSystemStorage.ts index 83493f67..1935638d 100644 --- a/src/storage/fileSystemStorage.ts +++ b/src/storage/fileSystemStorage.ts @@ -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)