summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Lukas <georg@op-co.de>2021-12-10 14:45:14 +0100
committerGeorg Lukas <georg@op-co.de>2021-12-11 19:06:09 +0100
commite1a75a5cedbef8a669c1156a681ce95096aacc5a (patch)
treeb4514c5ad7f7a9f1448c536278797df9028e71f0
parent1d681fb04cd551dcad6177f0391ed86730767fd6 (diff)
downloadpoezio-e1a75a5cedbef8a669c1156a681ce95096aacc5a.tar.gz
poezio-e1a75a5cedbef8a669c1156a681ce95096aacc5a.tar.bz2
poezio-e1a75a5cedbef8a669c1156a681ce95096aacc5a.tar.xz
poezio-e1a75a5cedbef8a669c1156a681ce95096aacc5a.zip
Logger: jidstr is not a valid JID with MUC-PMs
The logger often operates on filenames for log files and assumes that jid == filename, but MUC-PM filenames are `muc@domain\nick` (jidstr) instead of `muc@domain/nick` (jid) and the former is not a valid JID. This patch fixes the places where jid and jidstr are mixed up.
-rw-r--r--poezio/logger.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/poezio/logger.py b/poezio/logger.py
index 6e4a6ff0..9a901836 100644
--- a/poezio/logger.py
+++ b/poezio/logger.py
@@ -157,11 +157,11 @@ class Logger:
def close(self, jid: str) -> None:
"""Close the log file for a JID."""
- jid = str(jid).replace('/', '\\')
- if jid in self._fds:
- self._fds[jid].close()
+ jidstr = str(jid).replace('/', '\\')
+ if jidstr in self._fds:
+ self._fds[jidstr].close()
log.debug('Log file for %s closed.', jid)
- del self._fds[jid]
+ del self._fds[jidstr]
def reload_all(self) -> None:
"""Close and reload all the file handles (on SIGHUP)"""
@@ -251,18 +251,18 @@ class Logger:
:param force: Bypass the buffered fd check
:returns: True if no error was encountered
"""
- jid = str(jid).replace('/', '\\')
- if jid in self._fds.keys():
- fd = self._fds[jid]
+ jidstr = str(jid).replace('/', '\\')
+ if jidstr in self._fds.keys():
+ fd = self._fds[jidstr]
else:
option_fd = self._check_and_create_log_dir(jid)
if option_fd is None:
return True
fd = option_fd
- filename = self.log_dir / jid
+ filename = self.log_dir / jidstr
try:
- if not force and self._busy_fds.get(jid):
- self._buffered_fds[jid].append(logged_msg)
+ if not force and self._busy_fds.get(jidstr):
+ self._buffered_fds[jidstr].append(logged_msg)
return True
fd.write(logged_msg)
except OSError: