handle_user_provided_file leaves an empty temp file
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start from the definition of handle_user_provided_file() in python-scraperlib and trace the nocopy=True early return and the local-path existence check that run before the temporary file is created. Move the NamedTemporaryFile(delete=False) creation into only the download and copy branches. Add tests asserting in_dir stays empty for the nocopy local-path case and for the missing local path, and confirm those tests fail before the change and pass after it.
Written by the indexing model from the issue text.
Description
When dest is not given, handle_user_provided_file() creates a NamedTemporaryFile(delete=False) before it knows whether it needs one. Two paths never use it, so an empty file is left behind:
nocopy=Truewith a local path returnssource, and the temp file stays inin_dir(or the system temp directory).- A local path that does not exist raises
OSError, and the temp file stays too.
nautilus (collection file) and kolibri2zim (custom about page and CSS, with in_dir=self.build_dir) call it with nocopy=True, so each of those runs given a local path leaves an empty tmp* file.
Proposed fix: create the temporary dest only in the download and copy branches, after the nocopy return and the existence check, and add tests that in_dir stays empty in both cases.
- Dominant language
- Python
- Stars
- 33
- Forks
- 34
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 24
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openzim/python-scraperlib
-
HtmlRewriter: title is cut at the first `&` (entity or bare ampersand)Possibly taken @rajanpanth claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
openzim/python-scraperlib#401 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
[next major] Remove deprecated 'convert' parameter for optimize_image function inside optimization.pyPossibly taken @Sriram-Nambiar claimed this 40 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openzim/python-scraperlib#292 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
compute_tags keeps empty tagsPossibly taken @ahmershahdev claimed this 1 day ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 32/100
openzim/python-scraperlib#412 · 1 comment ·
Maintainers usually reply within 1 day
-
Release 5.7.0Possibly taken @benoit74 claimed this 4 days ago. Open
openzim/python-scraperlib#411 · 1 assignee ·
Maintainers usually reply within 1 day
-
colorthief is unmaintained and will break with Pillow 14Possibly taken @anshuman83-40 claimed this 26 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
openzim/python-scraperlib#365 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in openzim/python-scraperlib
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
vllm-project/vllm#69791 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
BCStudentSoftwareDevTeam/cas#481 ·
Maintainers usually reply within 7 days
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day