From 12fa3432a9a2ba447e211365166e875963033b03 Mon Sep 17 00:00:00 2001 From: seth-milojevic <52462300+seth-milojevic@users.noreply.github.com> Date: Sat, 8 Feb 2025 00:20:10 -0500 Subject: [PATCH 1/2] Close file descriptor generated from tempfile.mkstemp() 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. --- beets/util/__init__.py | 5 ++++- docs/changelog.rst | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 32a63b216..ac4e3bc3c 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -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) diff --git a/docs/changelog.rst b/docs/changelog.rst index 62cd0c4cc..b39e1b291 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,6 +22,9 @@ New features: Bug fixes: +* 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 From 6205e19b74bc529d3b0a5a95bccd142dd5b1c127 Mon Sep 17 00:00:00 2001 From: seth-milojevic <52462300+seth-milojevic@users.noreply.github.com> Date: Sat, 8 Feb 2025 12:41:37 -0500 Subject: [PATCH 2/2] Update docs/changelog.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Šarūnas Nejus --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b39e1b291..fd1149178 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -22,7 +22,7 @@ New features: Bug fixes: -* Fix fetchart bug where a tempfile could not be deleted due to never being +* :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