Skip to content

Commit f80c831

Browse files
Fix ConfigManagingActor crash when any file was deleted
`event.path.samefile` raises error if: * `event.pathq` doesn't exists * path `p` doesn't exists In this case it raised exception if any file in parent directory was deleted. Signed-off-by: Elzbieta Kotulska <[email protected]>
1 parent dd7c65f commit f80c831

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/frequenz/sdk/config/_config_managing.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ async def _run(self) -> None:
164164

165165
try:
166166
async for event in file_watcher:
167+
if event.type == EventType.DELETE:
168+
if event.path in self._config_paths:
169+
_logger.info(
170+
"%s: The configuration file %s was deleted, ignoring...",
171+
self,
172+
event.path,
173+
)
174+
continue
175+
167176
# Since we are watching the whole parent directories, we need to make
168177
# sure we only react to events related to the configuration files we
169178
# are interested in.
@@ -185,12 +194,6 @@ async def _run(self) -> None:
185194
event.path,
186195
)
187196
await self.send_config()
188-
case EventType.DELETE:
189-
_logger.info(
190-
"%s: The configuration file %s was deleted, ignoring...",
191-
self,
192-
event.path,
193-
)
194197
case _:
195198
assert_never(event.type)
196199
finally:

0 commit comments

Comments
 (0)