adds Clean Copy Support
This commit is contained in:
@@ -9,6 +9,8 @@ public enum WatchEvent: Sendable, Equatable {
|
||||
case git
|
||||
/// `.helder/config.json` changed.
|
||||
case config
|
||||
/// `.clean-copy` in the project root changed; it also counts as a project change.
|
||||
case cleanCopy
|
||||
}
|
||||
|
||||
public protocol FileWatching: AnyObject {
|
||||
@@ -22,11 +24,14 @@ public struct WatchDebounce: Sendable, Equatable {
|
||||
public var project: TimeInterval
|
||||
public var git: TimeInterval
|
||||
public var config: TimeInterval
|
||||
/// The agent's write is not atomic, so the file is read only once it stopped changing.
|
||||
public var cleanCopy: TimeInterval
|
||||
|
||||
public init(project: TimeInterval, git: TimeInterval, config: TimeInterval) {
|
||||
public init(project: TimeInterval, git: TimeInterval, config: TimeInterval, cleanCopy: TimeInterval = 0.15) {
|
||||
self.project = project
|
||||
self.git = git
|
||||
self.config = config
|
||||
self.cleanCopy = cleanCopy
|
||||
}
|
||||
|
||||
public static let standard = WatchDebounce(project: 0.25, git: 0.2, config: 0.1)
|
||||
@@ -36,6 +41,7 @@ public struct WatchDebounce: Sendable, Equatable {
|
||||
case .project: project
|
||||
case .git: git
|
||||
case .config: config
|
||||
case .cleanCopy: cleanCopy
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +151,7 @@ final class EventRouter: @unchecked Sendable {
|
||||
}
|
||||
|
||||
func route(path: String, flags: FSEventStreamEventFlags) {
|
||||
if Self.relative(path, to: root) == CleanCopy.fileName { schedule(.cleanCopy) }
|
||||
guard let event = Self.classify(path: path, root: root, gitDirectory: gitDirectory, flags: flags, exclude: files.exclude) else {
|
||||
return
|
||||
}
|
||||
@@ -163,6 +170,8 @@ final class EventRouter: @unchecked Sendable {
|
||||
case .config:
|
||||
files = Self.readFiles(root: rootURL)
|
||||
ignoredCache = [:]
|
||||
case .cleanCopy:
|
||||
break
|
||||
}
|
||||
schedule(event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user