Skip to content

Commit 8032404

Browse files
committed
Suffix temporary directory with unique path
Fixes #529 Reusing the temporary directory can cause issues with concurrent instances of Danger. By appending a unique identifier we can prevent race conditions when running Danger from concurrent processes.
1 parent a432241 commit 8032404

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
## Master
1515

1616
- Drop Swift 5.3 support [@417-72KI][] - [#524](https://github.com/danger/swift/pull/524)
17+
- Refine runner temporary path to better support concurrent pipelines [@squarefrog][] - [#530](https://github.com/danger/swift/pull/530)
1718

1819
## 3.13.0
1920

Sources/Runner/Commands/Runner.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ func runDanger(logger: Logger) throws {
99
// Pull in the JSON from Danger JS
1010
let standardInput = FileHandle.standardInput
1111
let fileManager = FileManager.default
12-
let tmpPath = NSTemporaryDirectory()
12+
let tmpPath = NSTemporaryDirectory() + "danger/\(UUID().uuidString)/"
1313
let dangerResponsePath = tmpPath + "danger-response.json"
1414

15+
try fileManager.createDirectory(
16+
at: URL(fileURLWithPath: tmpPath),
17+
withIntermediateDirectories: true
18+
)
19+
1520
// Pull in the JSON from Danger JS
1621
guard let dangerDSLURL = String(data: standardInput.readDataToEndOfFile(), encoding: .utf8) else {
1722
logger.logError("Could get the Dangerfile DSL URL from STDing")

0 commit comments

Comments
 (0)