diff options
author | Doug Nazar <nazard@nazar.ca> | 2021-05-07 06:00:57 +0300 |
---|---|---|
committer | Doug Nazar <nazard@nazar.ca> | 2021-05-07 06:04:27 +0300 |
commit | c71805c565b10bf31db239ad46a0768cba9de8b0 (patch) | |
tree | 0314ae0e57d73eabf7395a2a59986a08eafae7cc | |
parent | 135f517ea376efd6b07f91ce738d262cb0458897 (diff) |
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/814>
-rw-r--r-- | plugins/elements/gstdownloadbuffer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/elements/gstdownloadbuffer.c b/plugins/elements/gstdownloadbuffer.c index b9d512b67f..6d01bf91b9 100644 --- a/plugins/elements/gstdownloadbuffer.c +++ b/plugins/elements/gstdownloadbuffer.c @@ -963,15 +963,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 |