Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Glob crash #1181

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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