diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c2b2fee..0d51335 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +1.0.5: +- Remove lockfile creation when the updater process is skipped per the environment variable introduced in 1.0.4 + 1.0.4: - Skipping the startup update with setting an environment variable called `PY3VE_IGNORE_UPDATER` diff --git a/setup.py b/setup.py index 3a7e6f1..bb0246e 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ class BuildPyCommand(build_py): setup( name='py3-validate-email', - version='1.0.4', + version='1.0.5', packages=find_packages(exclude=['tests']), install_requires=['dnspython~=2.1', 'idna~=3.0', 'filelock~=3.0'], author='László Károlyi', diff --git a/validate_email/domainlist_check.py b/validate_email/domainlist_check.py index 8217972..b1ec47c 100644 --- a/validate_email/domainlist_check.py +++ b/validate_email/domainlist_check.py @@ -40,17 +40,26 @@ class DomainListValidator(object): except FileNotFoundError: return BLACKLIST_FILEPATH_INSTALLED + def _get_blacklist_lines(self) -> list: + 'Return the lines of blacklist.txt as a list.' + bl_path = self._blacklist_path + LOGGER.debug(msg=f'(Re)loading blacklist from {bl_path}') + try: + with open(bl_path) as fd: + return fd.readlines() + except FileNotFoundError: + return [] + def reload_builtin_blacklist(self): '(Re)load our built-in blacklist.' - TMP_PATH.mkdir(exist_ok=True) - with FileLock(lock_file=str(LOCK_PATH)): - bl_path = self._blacklist_path - LOGGER.debug(msg=f'(Re)loading blacklist from {bl_path}') - try: - with open(bl_path) as fd: - lines = fd.readlines() - except FileNotFoundError: - return + # Locking is only necessary when we might have an updater + # process running + if ENV_IGNORE_UPDATER: + lines = self._get_blacklist_lines() + else: + TMP_PATH.mkdir(exist_ok=True) + with FileLock(lock_file=str(LOCK_PATH)): + lines = self._get_blacklist_lines() self.domain_blacklist = set( x.strip().lower() for x in lines if x.strip())