From b4d20d0f287b5ca04aca0c4f5a0eec61577a68eb Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Tue, 27 Jun 2017 01:59:26 -0700 Subject: [PATCH] Fix #430: Close open file handle before renaming file affecting Windows --- src/Curl/Curl.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index c11cc37..5737ef7 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -298,7 +298,12 @@ class Curl $this->fileHandle = fopen($download_filename, $mode); // Move the downloaded temporary file to the destination save path. - $this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) { + $this->downloadCompleteFunction = function ($instance, $fh) use ($download_filename, $filename) { + // Close the open file handle before renaming the file. + if (is_resource($fh)) { + fclose($fh); + } + rename($download_filename, $filename); }; }