Merge branch '1.0' into 2.0

This commit is contained in:
terrafrost 2020-07-30 22:58:56 -05:00
commit 82406869fb

View File

@ -259,6 +259,16 @@ class SFTP extends SSH2
*/
var $requestBuffer = array();
/**
* Preserve timestamps on file downloads / uploads
*
* @see self::get()
* @see self::put()
* @var bool
* @access private
*/
var $preserveTime = false;
/**
* Default Constructor.
*
@ -2075,6 +2085,11 @@ class SFTP extends SSH2
}
if ($mode & self::SOURCE_LOCAL_FILE) {
if ($this->preserveTime) {
$stat = fstat($fp);
$this->touch($remote_file, $stat['mtime'], $stat['atime']);
}
fclose($fp);
}
@ -2292,6 +2307,11 @@ class SFTP extends SSH2
if ($fclose_check) {
fclose($fp);
if ($this->preserveTime) {
$stat = $this->stat($remote_file);
touch($local_file, $stat['mtime'], $stat['atime']);
}
}
if (!$this->_close_handle($handle)) {
@ -3176,4 +3196,24 @@ class SFTP extends SSH2
$this->pwd = false;
parent::_disconnect($reason);
}
/**
* Enable Date Preservation
*
* @access public
*/
function enableDatePreservation()
{
$this->preserveTime = true;
}
/**
* Disable Date Preservation
*
* @access public
*/
function disableDatePreservation()
{
$this->preserveTime = false;
}
}