Skip to content
Open
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
4 changes: 2 additions & 2 deletions pytr/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ def dl_doc(self, doc, titleText, subfolder, doc_date, subtitle="", subdir_overri
filepath = sanitize_filepath(filepath, "_", "auto")
filepath_with_doc_id = sanitize_filepath(filepath_with_doc_id, "_", "auto")

if filepath in self.filepaths:
if str(filepath) in self.filepaths:
self.log.debug(f"File {filepath} already in queue. Append document id {doc_id}...")
if filepath_with_doc_id in self.filepaths:
if str(filepath_with_doc_id) in self.filepaths:
self.log.debug(f"File {filepath_with_doc_id} already in queue. Skipping...")
return
else:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_dl_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import json
import logging
from datetime import datetime
from pathlib import Path

import pytest
Expand Down Expand Up @@ -392,3 +393,15 @@ def collect_paths(fixture_name: str, tmp_path: Path) -> list[str]:
@pytest.mark.parametrize("case", test_data, ids=[c["filename"] for c in test_data])
def test_dl_paths(case, tmp_path):
assert collect_paths(case["filename"], tmp_path) == case["paths"]


def test_dl_paths_same_minute_same_title(tmp_path):
"""Two documents rendering to the same name (minute precision) must not share a file."""
dl = make_dl(tmp_path)
with open(EVENTS_DIR / "buy_new.json", encoding="utf-8") as f:
doc = json.load(f)["details"]["sections"][-1]["data"][0]
other = {**doc, "id": "other-id"}
title, when = "Abrechnung - NVIDIA - Kauforder", datetime(2025, 10, 10, 19, 29)
dl.dl_doc(doc, title, "Trades", when)
dl.dl_doc(other, title, "Trades", when)
assert other["local_filepath"].endswith(" (other-id).pdf")