mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-09 05:40:07 +01:00
🐛 Do not watch files that do not exist (#123)
This commit is contained in:
@@ -27,13 +27,13 @@ class Log {
|
|||||||
|
|
||||||
static func err(_ item: Any) {
|
static func err(_ item: Any) {
|
||||||
if Verbosity.error.isApplicable() {
|
if Verbosity.error.isApplicable() {
|
||||||
print(item)
|
print("[ERR] \(item)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func warn(_ item: Any) {
|
static func warn(_ item: Any) {
|
||||||
if Verbosity.warning.isApplicable() {
|
if Verbosity.warning.isApplicable() {
|
||||||
print(item)
|
print("[WRN] \(item)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ class PhpConfigWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addWatcher(for url: URL, eventMask: DispatchSource.FileSystemEvent, behaviour: FSWatcherBehaviour = .reloadsMenu) {
|
func addWatcher(for url: URL, eventMask: DispatchSource.FileSystemEvent, behaviour: FSWatcherBehaviour = .reloadsMenu) {
|
||||||
|
if !Filesystem.fileExists(url.path) {
|
||||||
|
Log.warn("No watcher was created for \(url.path) because the requested file does not exist.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let watcher = FSWatcher(for: url, eventMask: eventMask, parent: self, behaviour: behaviour)
|
let watcher = FSWatcher(for: url, eventMask: eventMask, parent: self, behaviour: behaviour)
|
||||||
self.watchers.append(watcher)
|
self.watchers.append(watcher)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user