mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 16:31:36 +00:00
* style: apply SwiftFormat 0.62.1 rules Refs #103202 * ci: enforce deterministic Swift lint Refs #103202 * refactor: keep gateway connect lint-clean Refs #103202 * style: keep iOS typography checks warning-free * ci: route MLX Swift changes through pre-push * fix: preserve native i18n extraction after Swift cleanup * refactor: keep rebased Swift surfaces lint-clean * style: format latest Swift additions * chore: refresh native i18n inventory * style: keep generated Swift formatter-clean * fix: preserve node route invalidation callbacks * fix: keep native translation IDs stable * fix: retain native translation identifiers * fix: preserve translations across Swift source moves
40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
final class ConfigFileWatcher: @unchecked Sendable, SimpleFileWatcherOwner {
|
|
private let url: URL
|
|
private let watchedDir: URL
|
|
private let targetPath: String
|
|
private let targetName: String
|
|
let watcher: SimpleFileWatcher
|
|
|
|
init(url: URL, onChange: @escaping () -> Void) {
|
|
self.url = url
|
|
self.watchedDir = url.deletingLastPathComponent()
|
|
self.targetPath = url.path
|
|
self.targetName = url.lastPathComponent
|
|
let watchedDirPath = self.watchedDir.path
|
|
let targetPath = self.targetPath
|
|
let targetName = self.targetName
|
|
self.watcher = SimpleFileWatcher(CoalescingFSEventsWatcher(
|
|
paths: [watchedDirPath],
|
|
queueLabel: "ai.openclaw.configwatcher",
|
|
shouldNotify: { _, eventPaths in
|
|
guard let eventPaths else { return true }
|
|
let paths = unsafeBitCast(eventPaths, to: NSArray.self)
|
|
for case let path as String in paths {
|
|
if path == targetPath {
|
|
return true
|
|
}
|
|
if path.hasSuffix("/\(targetName)") {
|
|
return true
|
|
}
|
|
if path == watchedDirPath {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
},
|
|
onChange: onChange))
|
|
}
|
|
}
|