File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ def __init__(
49
49
if isinstance (config_path , pathlib .Path )
50
50
else pathlib .Path (config_path )
51
51
)
52
+ # FileWatcher can't watch for non-existing files, so we need to watch for the
53
+ # parent directory instead just in case a configuration file doesn't exist yet
54
+ # or it is deleted and recreated again.
52
55
self ._file_watcher : FileWatcher = FileWatcher (
53
56
paths = [self ._config_path .parent ], event_types = event_types
54
57
)
@@ -82,6 +85,8 @@ async def run(self) -> None:
82
85
83
86
async for event in self ._file_watcher :
84
87
if event .type != FileWatcher .EventType .DELETE :
88
+ # Since we are watching the whole parent directory, we need to make sure
89
+ # we only react to events related to the configuration file.
85
90
if event .path == self ._config_path :
86
91
_logger .info (
87
92
"%s: Update configs, because file %s was modified." ,
You can’t perform that action at this time.
0 commit comments