mirror of
https://github.com/chatmail/relay.git
synced 2026-08-29 19:43:14 +00:00
fix: actually use UTC time instead of just seemingly using it
datetime.now(timezone.utc).timestamp() is actually 7200 seconds in the past. The Python deprecation warning of utcnow() warning actually pointed there.
This commit is contained in:
@@ -259,7 +259,7 @@ def daily_expire_main(args=None):
|
||||
args = parser.parse_args(args)
|
||||
|
||||
config = read_config(args.chatmail_ini)
|
||||
now = datetime.utcnow().timestamp()
|
||||
now = time.time()
|
||||
if args.days:
|
||||
now = now - 86400 * int(args.days)
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ to also write legacy metrics.py style output (default: /var/www/html/metrics):
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
from argparse import ArgumentParser
|
||||
from datetime import datetime
|
||||
|
||||
@@ -264,7 +265,7 @@ def main(args=None):
|
||||
|
||||
config = read_config(args.chatmail_ini)
|
||||
|
||||
now = datetime.utcnow().timestamp()
|
||||
now = time.time()
|
||||
if args.days:
|
||||
now = now - 86400 * int(args.days)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import os
|
||||
import random
|
||||
import shutil
|
||||
import time
|
||||
from datetime import datetime
|
||||
from fnmatch import fnmatch
|
||||
from pathlib import Path
|
||||
|
||||
@@ -41,7 +40,7 @@ def fill_mbox(folderdir):
|
||||
|
||||
|
||||
def create_new_messages(basedir, relpaths, size=1000, days=0):
|
||||
now = datetime.utcnow().timestamp()
|
||||
now = time.time()
|
||||
|
||||
for relpath in relpaths:
|
||||
msg_path = Path(basedir).joinpath(relpath)
|
||||
@@ -112,9 +111,7 @@ def test_mbox_without_password(mbox1, example_config, capsys):
|
||||
mbox_rescan = MailboxStat(mbox1.basedir)
|
||||
assert mbox_rescan.last_login is None
|
||||
|
||||
exp = Expiry(
|
||||
example_config, dry=False, now=datetime.now().timestamp(), verbose=False
|
||||
)
|
||||
exp = Expiry(example_config, dry=False, now=time.time(), verbose=False)
|
||||
exp.process_mailbox_stat(mbox_rescan)
|
||||
out, err = capsys.readouterr()
|
||||
assert "doesn't have last_login but isn't empty" in err
|
||||
@@ -152,7 +149,7 @@ def test_report_mdir_filters_by_path(mbox1, example_config):
|
||||
"""Test that Report with mdir='cur' only counts messages in cur/ subdirectory."""
|
||||
from chatmaild.fsreport import Report
|
||||
|
||||
now = datetime.utcnow().timestamp()
|
||||
now = time.time()
|
||||
|
||||
# Set password mtime to old enough so min_login_age check passes
|
||||
password = Path(mbox1.basedir).joinpath("password")
|
||||
|
||||
Reference in New Issue
Block a user