Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ def _sync_to_local_dir_if_changed(self, s3_bucket, s3_object, local_target_path:
)

s3_last_modified = s3_object.last_modified
if local_stats.st_mtime < s3_last_modified.microsecond:
if local_stats.st_mtime < s3_last_modified.timestamp():
should_download = True
download_msg = f"S3 object last modified ({s3_last_modified.microsecond}) and local file last modified ({local_stats.st_mtime}) differ."

Expand Down
17 changes: 17 additions & 0 deletions providers/amazon/tests/unit/amazon/aws/hooks/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,23 @@ def get_logs_string(call_args_list):
assert "S3 object size" in logs_string
assert "differ. Downloaded dag_03.py to" in logs_string

local_file_same_size = Path(sync_local_dir).joinpath("dag_04.py")
local_file_same_size.write_text("same size")

s3_client.put_object(Bucket=s3_bucket, Key="dag_04.py", Body=b"same size")

prev_ts = local_file_same_size.stat().st_mtime - 5
os.utime(local_file_same_size, (prev_ts, prev_ts))

hook.log.debug = MagicMock()
hook.sync_to_local_dir(
bucket_name=s3_bucket, local_dir=sync_local_dir, s3_prefix="", delete_stale=True
)
logs_string = get_logs_string(hook.log.debug.call_args_list)
assert "S3 object last modified" in logs_string
assert "local file last modified" in logs_string
assert "differ. Downloaded dag_04.py to" in logs_string


@pytest.mark.parametrize(
("key_kind", "has_conn", "has_bucket", "precedence", "expected"),
Expand Down