fixed receiveFile() and changed color for DOWNLOAD label
This commit is contained in:
@ -118,12 +118,23 @@ class SFTPConnection
|
|||||||
public function receiveFile($remote_file, $local_file)
|
public function receiveFile($remote_file, $local_file)
|
||||||
{
|
{
|
||||||
$sftp = $this->sftp;
|
$sftp = $this->sftp;
|
||||||
$stream = @fopen("ssh2.sftp://$sftp$remote_file", 'r');
|
$remote_stream = @fopen("ssh2.sftp://$sftp$remote_file", 'rb');
|
||||||
if (! $stream)
|
if (! $remote_stream)
|
||||||
throw new Exception("Could not open SFTP file for reading: $remote_file");
|
throw new Exception("Could not open SFTP file for reading: $remote_file");
|
||||||
$contents = fread($stream, filesize("ssh2.sftp://$sftp$remote_file"));
|
|
||||||
file_put_contents($local_file, $contents);
|
$local_stream = @fopen($local_file, 'wb');
|
||||||
@fclose($stream);
|
if (! $local_stream) {
|
||||||
|
@fclose($remote_stream);
|
||||||
|
throw new Exception("Could not open local file for writing: $local_file");
|
||||||
|
}
|
||||||
|
|
||||||
|
$copied = @stream_copy_to_stream($remote_stream, $local_stream);
|
||||||
|
@fclose($local_stream);
|
||||||
|
@fclose($remote_stream);
|
||||||
|
|
||||||
|
if ($copied === false) {
|
||||||
|
throw new Exception("Could not receive data from file: $remote_file.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function statFile($remote_file)
|
public function statFile($remote_file)
|
||||||
|
|||||||
@ -988,7 +988,7 @@ function getStatusMeta(string $status): array
|
|||||||
'MKDIR' => ['icon' => '📁', 'color' => '36'],
|
'MKDIR' => ['icon' => '📁', 'color' => '36'],
|
||||||
'RMDIR' => ['icon' => '🧹', 'color' => '35'],
|
'RMDIR' => ['icon' => '🧹', 'color' => '35'],
|
||||||
'UPLOAD' => ['icon' => '⬆️', 'color' => '32'],
|
'UPLOAD' => ['icon' => '⬆️', 'color' => '32'],
|
||||||
'DOWNLOAD' => ['icon' => '⬇️', 'color' => '34'],
|
'DOWNLOAD' => ['icon' => '⬇️', 'color' => '36'],
|
||||||
'DELETE' => ['icon' => '🗑️', 'color' => '31'],
|
'DELETE' => ['icon' => '🗑️', 'color' => '31'],
|
||||||
'SKIP' => ['icon' => '⏭️', 'color' => '33'],
|
'SKIP' => ['icon' => '⏭️', 'color' => '33'],
|
||||||
'ERROR' => ['icon' => '❌', 'color' => '91'],
|
'ERROR' => ['icon' => '❌', 'color' => '91'],
|
||||||
|
|||||||
Reference in New Issue
Block a user