From 42a875b0fe0150f5482d55a87fec663e76352bfe Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 2 Aug 2021 16:54:14 -0700 Subject: [PATCH] matrix-eavesdrop: fix initial room path creation The bot is supposed to create the filesystem director for the room path when joining, but it may have done so with a relative path instead of the full path that is actually used for logging. Change-Id: I8c9c19a12eb2b85797ade75358859dc06b81b0b6 --- docker/matrix-eavesdrop/src/eavesdrop/bot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docker/matrix-eavesdrop/src/eavesdrop/bot.py b/docker/matrix-eavesdrop/src/eavesdrop/bot.py index 2e7622d1a4..01e7a16e85 100644 --- a/docker/matrix-eavesdrop/src/eavesdrop/bot.py +++ b/docker/matrix-eavesdrop/src/eavesdrop/bot.py @@ -94,6 +94,12 @@ class Bot: data = json.load(f) return data + def get_room_path(self, room): + room_path = room['path'] + if not room_path.startswith('/'): + room_path = os.path.join(self.config['log_dir'], room_path) + return room_path + async def join_rooms(self): new = set() old = set() @@ -107,7 +113,7 @@ class Bot: # Store the canonical room id, since the one in the config # file may be an alias self.room_map[resp.room_id] = room - os.makedirs(room['path'], exist_ok=True) + os.makedirs(self.get_room_path(room), exist_ok=True) for room in old-new: self.log.info("Leave room %s", room['id']) await self.client.room_leave(room) @@ -120,9 +126,7 @@ class Bot: ts = datetime.datetime.utcfromtimestamp(event.server_timestamp/1000.0) event_date = str(ts.date()) event_time = str(ts.time())[:8] - room_path = config_room['path'] - if not room_path.startswith('/'): - room_path = os.path.join(self.config['log_dir'], room_path) + room_path = self.get_room_path(config_room) filename = f'{room_name}.{event_date}.log' logpath = os.path.join(room_path, filename) body = event.body