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:
parent
e7dcedae60
commit
3fe2a6e7f0
1 changed files with 8 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue