Skip to content

Commit

Permalink
Merge pull request #133 from Matthew-Grayson/develop
Browse files Browse the repository at this point in the history
Fixes issue 132 (Public Suffix List (PSL) Updates Too Often)
  • Loading branch information
jsf9k authored Sep 12, 2023
2 parents 16ce619 + eba45b9 commit 08430e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/trustymail/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""This file defines the version of this module."""
__version__ = "0.8.1"
__version__ = "0.8.2"
4 changes: 3 additions & 1 deletion src/trustymail/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Standard Python Libraries
from collections import OrderedDict
from datetime import datetime, timedelta
from os import path, stat
from os import path, stat, utime
from typing import Dict

# Third-Party Libraries
Expand All @@ -24,12 +24,14 @@ def get_psl():
if not PublicSuffixListReadOnly:
if not path.exists(PublicSuffixListFilename):
updatePSL(PublicSuffixListFilename)
utime(PublicSuffixListFilename, None) # Set mtime to now
else:
psl_age = datetime.now() - datetime.fromtimestamp(
stat(PublicSuffixListFilename).st_mtime
)
if psl_age > timedelta(hours=24):
updatePSL(PublicSuffixListFilename)
utime(PublicSuffixListFilename, None) # Set mtime to now

with open(PublicSuffixListFilename, encoding="utf-8") as psl_file:
psl = PublicSuffixList(psl_file)
Expand Down

0 comments on commit 08430e2

Please sign in to comment.