Skip to content

Commit b1e150e

Browse files
authored
Merge pull request php-curl-class#453 from zachborboa/fix-430
Fix php-curl-class#430: Close open file handle before renaming file affecting Windows
2 parents 3b672a2 + e28baa9 commit b1e150e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ php:
1212

1313
matrix:
1414
allow_failures:
15+
- php: hhvm
1516
- php: nightly
1617

1718
before_script:

src/Curl/Curl.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,12 @@ public function download($url, $mixed_filename)
298298
$this->fileHandle = fopen($download_filename, $mode);
299299

300300
// Move the downloaded temporary file to the destination save path.
301-
$this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) {
301+
$this->downloadCompleteFunction = function ($instance, $fh) use ($download_filename, $filename) {
302+
// Close the open file handle before renaming the file.
303+
if (is_resource($fh)) {
304+
fclose($fh);
305+
}
306+
302307
rename($download_filename, $filename);
303308
};
304309
}

0 commit comments

Comments
 (0)