Repository navigation
fix(dl): compare queued paths as strings so same-name documents get their id appended - #407
Open
leonlowitzki wants to merge 1 commit into
Open
leonlowitzki wants to merge 1 commit into
leonlowitzki wants to merge 1 commit into
Conversation
…heir id appended self.filepaths holds str, but the duplicate check tested a Path against it, which never matches. Two orders of one instrument executed within the same minute therefore rendered to one file name and the later download overwrote the earlier one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two orders of the same instrument executed within the same minute end up as one PDF: the later download overwrites the earlier one.
Cause
dl_docalready handles this case: if the computed path is already queued, it appends the document id (dl.py:455-462). But the check never fires:Path("a.pdf") in ["a.pdf"]isFalse, so both documents are queued under the same path and the second write wins.Real-world case
Two limit buys of the same stock, executed 27 seconds apart within one minute. Both render to
Trades/<date> <HH:MM> Abrechnung - <name> - Limit-Buy-Order.pdf; only the later settlement survived. Same forAuftragsbestätigungandKosteninformation.Fix
Compare as strings (two lines). The second document now lands at
… - Limit-Buy-Order (<doc id>).pdf, which is what the existing code intended.Test
test_dl_paths_same_minute_same_titlepasses the Abrechnung frombuy_new.jsonand a copy with another id throughdl_docwith the same title and minute. It fails onmaster(both get the same path) and passes with the fix. Full suite: 285 passed;ruff checkandruff format --checkclean.Scope
This fixes collisions within one run only. If the first document was downloaded in an earlier run, the second still hits
filepath.is_file()and is skipped. #398 (recognise documents by id, for #391) addresses the cross-run side; the two changes don't overlap.