From 20d4184a6904350e6df2cfb28dfde52bcbf0561b Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Thu, 6 May 2021 23:00:57 -0400 Subject: [PATCH] downloadbuffer: close file before trying to remove On Windows, the file handles must be closed before you can delete a file. Also, it would cause an error if you try to close an already closed handle. Part-of: --- plugins/elements/gstdownloadbuffer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/elements/gstdownloadbuffer.c b/plugins/elements/gstdownloadbuffer.c index 784d9fa0b0..d6ff62105c 100644 --- a/plugins/elements/gstdownloadbuffer.c +++ b/plugins/elements/gstdownloadbuffer.c @@ -960,15 +960,17 @@ gst_download_buffer_close_temp_location_file (GstDownloadBuffer * dlbuf) GST_DEBUG_OBJECT (dlbuf, "closing sparse file"); + gst_sparse_file_free (dlbuf->file); + dlbuf->file = NULL; + /* fd was closed by gst_sparse_file_free's fclose() */ + dlbuf->temp_fd = -1; + if (dlbuf->temp_remove) { if (remove (dlbuf->temp_location) < 0) { GST_WARNING_OBJECT (dlbuf, "Failed to remove temporary file %s: %s", dlbuf->temp_location, g_strerror (errno)); } } - gst_sparse_file_free (dlbuf->file); - close (dlbuf->temp_fd); - dlbuf->file = NULL; } static void