Close file descriptor generated from tempfile.mkstemp() (#5617)

Without explicitly closing this file descriptor, the temp file would be
kept open until the program exited and could not be deleted by the
fetchart plugin.

Fixes #5521
This commit is contained in:
Šarūnas Nejus 2025-02-09 00:58:44 +00:00 committed by GitHub
commit 810af1f87b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -1130,7 +1130,10 @@ def get_temp_filename(
tempdir = get_module_tempdir(module)
tempdir.mkdir(parents=True, exist_ok=True)
_, filename = tempfile.mkstemp(dir=tempdir, prefix=prefix, suffix=suffix)
descriptor, filename = tempfile.mkstemp(
dir=tempdir, prefix=prefix, suffix=suffix
)
os.close(descriptor)
return bytestring_path(filename)

View file

@ -22,6 +22,9 @@ New features:
Bug fixes:
* :doc:`plugins/fetchart`: Fix fetchart bug where a tempfile could not be deleted due to never being
properly closed.
:bug:`5521`
* :doc:`plugins/lyrics`: LRCLib will fallback to plain lyrics if synced lyrics
are not found and `synced` flag is set to `yes`.
* Synchronise files included in the source distribution with what we used to