Skip to content

Commit 27db461

Browse files
committed
Delete temporary files created during sourcekitd reduction
1 parent 98b0b23 commit 27db461

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Sources/Diagnose/CommandLineArgumentsReducer.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ fileprivate class CommandLineArgumentReducer {
3434

3535
init(sourcekitdExecutor: SourceKitRequestExecutor) {
3636
self.sourcekitdExecutor = sourcekitdExecutor
37-
temporarySourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduce.swift")
37+
temporarySourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduce-\(UUID()).swift")
38+
}
39+
40+
deinit {
41+
try? FileManager.default.removeItem(at: temporarySourceFile)
3842
}
3943

4044
func logSuccessfulReduction(_ requestInfo: RequestInfo) {

Sources/Diagnose/SourceReducer.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ fileprivate class SourceReducer {
6565

6666
init(sourcekitdExecutor: SourceKitRequestExecutor) {
6767
self.sourcekitdExecutor = sourcekitdExecutor
68-
temporarySourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduce.swift")
68+
temporarySourceFile = FileManager.default.temporaryDirectory.appendingPathComponent("reduce-\(UUID()).swift")
69+
}
70+
71+
deinit {
72+
try? FileManager.default.removeItem(at: temporarySourceFile)
6973
}
7074

7175
/// Reduce the file contents in `initialRequest` to a smaller file that still reproduces a crash.

0 commit comments

Comments
 (0)