Skip to content

Commit 3a5bf66

Browse files
Refactor data directory handling in Codebase class to improve logic for creation and removal. The existence check for the data directory is now separated, ensuring mkdirSync is only called when necessary.
1 parent a730c9f commit 3a5bf66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ingestion/src/process/prepare/codebase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ export class Codebase {
4545
this._dataDirPath = path.resolve(this._path, this._dataDirName)
4646

4747
/* Handle data directory */
48-
if (removeExisting && existsSync(this._dataDirPath)) rmSync(this._dataDirPath, { recursive: true })
49-
mkdirSync(this._dataDirPath)
48+
const exists = existsSync(this._dataDirPath)
49+
if (removeExisting && exists) rmSync(this._dataDirPath, { recursive: true })
50+
if (!exists) mkdirSync(this._dataDirPath)
5051
}
5152

5253
private prepareFilesMetadata() {

0 commit comments

Comments
 (0)