Browse Source

fix bug in minimail

PYADPT-55
Volker Birk 6 years ago
parent
commit
d6346a6b9c
  1. 7
      test/minimail.py
  2. 4
      test/sync_handshake.py

7
test/minimail.py

@ -19,6 +19,7 @@ delete the marker file to re-read all messages
# this file is under GNU General Public License 3.0 # this file is under GNU General Public License 3.0
import os
from secrets import token_urlsafe from secrets import token_urlsafe
from time import sleep from time import sleep
@ -78,12 +79,18 @@ def recv_all(inbox, marker):
r = [] r = []
while not r: while not r:
with Lock(inbox): with Lock(inbox):
newest = 0
for p in reversed([ path for path in inbox.glob("*.eml") ]): for p in reversed([ path for path in inbox.glob("*.eml") ]):
if newer(p, inbox / marker): if newer(p, inbox / marker):
with open(p, "rb") as f: with open(p, "rb") as f:
t = f.read(-1) t = f.read(-1)
r.append((p, t)) r.append((p, t))
t = p.stat().st_mtime
if t > newest:
newest = t
(inbox / marker).touch(exist_ok=True) (inbox / marker).touch(exist_ok=True)
os.utime(str(inbox / marker), (newest, newest))
if not r: if not r:
sleep(1) sleep(1)

4
test/sync_handshake.py

@ -53,13 +53,13 @@ def print_msg(p):
elif p.name[:6] == "Laptop": elif p.name[:6] == "Laptop":
color = "green" color = "green"
else: else:
color = None color = "lightblue"
with open(p, "r") as f: with open(p, "r") as f:
t = f.read(-1) t = f.read(-1)
msg = pEp.Message(t) msg = pEp.Message(t)
print("\n" + colored(p.name, color)) print("\n" + colored(p.name, color))
print(colored(str(datetime.fromtimestamp(p.stat().st_mtime)), color)) print(colored(str(datetime.fromtimestamp(p.stat().st_mtime)), color))
m = re.search("<payload>(.*)</payload>", msg.opt_fields["pEp.sync"].replace("\n", " ")) m = re.search("<keysync>(.*)</keysync>", msg.opt_fields["pEp.sync"].replace("\n", " "))
if m: if m:
if etree: if etree:
tree = objectify.fromstring(m.group(1).replace("\r", "")) tree = objectify.fromstring(m.group(1).replace("\r", ""))

Loading…
Cancel
Save