Skip to content

Commit 263436d

Browse files
authored
Merge pull request #530 from squarefrog/issue_529_fix_concurrent_temp_path
2 parents a432241 + 72c21bd commit 263436d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
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

+7-3
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")
@@ -172,8 +177,7 @@ func runDanger(logger: Logger) throws {
172177
logger.logError("Could not get the results JSON file at \(dangerResponsePath)")
173178
// Clean up after ourselves
174179
try? fileManager.removeItem(atPath: dslJSONPath)
175-
try? fileManager.removeItem(atPath: tempDangerfilePath)
176-
try? fileManager.removeItem(atPath: dangerResponsePath)
180+
try? fileManager.removeItem(atPath: tmpPath)
177181
exit(1)
178182
}
179183

0 commit comments

Comments
 (0)