Fixed Glob crash (#1181)

This commit is contained in:
Vladislav Lisyanskiy 2022-03-06 10:32:35 +03:00 committed by GitHub
parent d218ada92f
commit a10c7c4c24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -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

View File

@ -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 }
}
}
}

View File

@ -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]