Skip to content

Commit

Permalink
Fixed Glob crash (yonaskolb#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1ckyf0x committed Mar 6, 2022
1 parent d218ada commit a10c7c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Next Version

### Fixed

- Fixed crash caused by a simultaneous write during a glob processing [#1177](https://github.com/yonaskolb/XcodeGen/issues/1177) @tr1ckyf0x

## 2.26.0

### Added
Expand Down
27 changes: 27 additions & 0 deletions Sources/XcodeGenCore/Atomic.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Atomic.swift
//
//
// Created by Vladislav Lisianskii on 23.02.2022.
//

import Foundation

@propertyWrapper
struct Atomic<Value> {
private let queue = DispatchQueue(label: "com.xcodegencore.atomic")
private var value: Value

init(wrappedValue: Value) {
self.value = wrappedValue
}

var wrappedValue: Value {
get {
return queue.sync { value }
}
set {
queue.sync { value = newValue }
}
}
}
2 changes: 1 addition & 1 deletion Sources/XcodeGenCore/Glob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Glob: Collection {

public static let defaultBlacklistedDirectories = ["node_modules", "Pods"]

private var isDirectoryCache = [String: Bool]()
@Atomic private var isDirectoryCache = [String: Bool]()

public let behavior: Behavior
public let blacklistedDirectories: [String]
Expand Down

0 comments on commit a10c7c4

Please sign in to comment.