Upgrader: FTP: Cleanup temporary files during FTP download failures.

Props ruud@joyo
Fixes #34772


git-svn-id: https://develop.svn.wordpress.org/trunk@35777 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2015-12-06 17:06:53 +00:00
parent b5bbba2026
commit fc87f96e07
1 changed files with 9 additions and 4 deletions

View File

@ -116,12 +116,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$tempfile = wp_tempnam($file);
$temp = fopen($tempfile, 'w+');
if ( ! $temp )
if ( ! $temp ) {
unlink( $tempfile );
return false;
if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) )
}
if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
fclose( $temp );
unlink( $tempfile );
return false;
}
fseek( $temp, 0 ); // Skip back to the start of the file being written to
$contents = '';