Skip to content

Commit

Permalink
Handle different file creation date (ctime) implementation on Unix an…
Browse files Browse the repository at this point in the history
…d Windows
  • Loading branch information
Guts committed Aug 25, 2023
1 parent 55f7bf5 commit fb65336
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions geotribu_cli/utils/file_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
from http.client import HTTPMessage, HTTPResponse
from pathlib import Path
from sys import platform as opersys
from urllib.error import HTTPError, URLError
from urllib.request import (
BaseHandler,
Expand Down Expand Up @@ -67,9 +68,18 @@ def download_remote_file_to_local(
Path: path to the local file (should be the same as local_file_path)
"""
if local_file_path.exists():
# modification date varies depending on operating system: on some systems (like
# Unix) creation date is the time of the last metadata change, and, on others
# (like Windows), is the creation time for path.
if opersys == "win32":
mod_date_reference = "m"
else:
mod_date_reference = "c"

if is_file_older_than(
local_file_path=local_file_path,
expiration_rotating_hours=expiration_rotating_hours,
dt_reference_mode=mod_date_reference,
):
logger.info(
f"Local search index ({local_file_path}) is outdated: "
Expand Down

0 comments on commit fb65336

Please sign in to comment.