Skip to content

Commit

Permalink
fix: Avoid duplicated path issue for instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Jun 4, 2023
1 parent 3e868a2 commit 7eeee2e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions xmcl-runtime/lib/services/InstanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ export class InstanceService extends StatefulService<InstanceState> implements I
if (!existsSync(candidatePath)) {
instance.path = candidatePath
} else {
throw new InstanceException({
type: 'instanceNameDuplicated',
path: candidatePath,
name: payload.name,
})
// find the first available path
let i = 1
while (existsSync(candidatePath + i)) {
i++
}
instance.path = candidatePath + i
}
}

Expand Down

0 comments on commit 7eeee2e

Please sign in to comment.