Skip to content

Commit

Permalink
Merge pull request phingofficial#416 from siad007/patch-6
Browse files Browse the repository at this point in the history
Fixes phingofficial#462 - Added "skip on same size" to FtpDeployTask
  • Loading branch information
mrook committed Apr 3, 2015
2 parents 470240e + b8c7989 commit d78e699
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions classes/phing/tasks/ext/FtpDeployTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class FtpDeployTask extends Task
private $dirmode = false;
private $filemode = false;
private $rawDataFallback = false;
private $skipOnSameSize = false;

protected $logLevel = Project::MSG_VERBOSE;

Expand Down Expand Up @@ -177,6 +178,14 @@ public function setRawdatafallback($fallback)
$this->rawDataFallback = (bool) $fallback;
}

/**
* @param bool|string|int $skipOnSameSize
*/
public function setSkipOnSameSize($skipOnSameSize)
{
$this->skipOnSameSize = StringHelper::booleanValue($skipOnSameSize);
}

/**
* Nested adder, adds a set of files (nested fileset attribute).
*
Expand Down Expand Up @@ -338,6 +347,12 @@ public function main()
}

if (!$this->depends || ($local_filemtime > $remoteFileModificationTime)) {

if ($this->skipOnSameSize === true && $file->length() === $ftp->size($filename)) {
$this->log('Skipped ' . $file->getCanonicalPath(), $this->logLevel);
continue;
}

$this->log('Will copy ' . $file->getCanonicalPath() . ' to ' . $filename, $this->logLevel);
$ret = $ftp->put($file->getCanonicalPath(), $filename, true, $this->mode);
if (@PEAR::isError($ret)) {
Expand Down
7 changes: 7 additions & 0 deletions docs/docbook5/en/source/appendixes/optionaltasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,13 @@
</entry>
<entry>No</entry>
</row>
<row>
<entry><literal>skiponsamesize</literal></entry>
<entry><literal role="type">Boolean</literal></entry>
<entry>Skip upload, if file of same size exists.</entry>
<entry><literal>false</literal></entry>
<entry>No</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down

0 comments on commit d78e699

Please sign in to comment.