diff --git a/dist/phploy.phar b/dist/phploy.phar index 9c62ac2..c47fa33 100755 Binary files a/dist/phploy.phar and b/dist/phploy.phar differ diff --git a/src/PHPloy.php b/src/PHPloy.php index f1b78dd..f617e1c 100644 --- a/src/PHPloy.php +++ b/src/PHPloy.php @@ -465,6 +465,7 @@ public function prepareDefaults($iniShared = []) 'passive' => null, 'timeout' => null, 'ssl' => false, + 'uploadRename' => false, 'visibility' => 'public', 'permPublic' => 0774, 'permPrivate' => 0700, @@ -960,7 +961,7 @@ public function deploy() // Done if (!$this->listFiles) { - $this->cli->bold()->lightGreen("\r\n|---------------[ ".human_filesize($this->deploymentSize).' Deployed ]---------------|'); + $this->cli->bold()->lightGreen("\r\n|---------------[ ".human_filesize($this->deploymentSize).' Deployed @ '.date('Y-m-d H:i:s').' ]---------------|'); $this->deploymentSize = 0; } } @@ -1189,9 +1190,15 @@ public function push($files, $localRevision = null) } // If base is set, remove it from filename - $remoteFile = $fileBaseless; + $remoteFile = $upload_remoteFile = $fileBaseless; + + //If uploadRename is enabled lets add a _tmp to file string + if($this->servers[$this->currentServerName]['uploadRename']) { + $upload_remoteFile = $remoteFile.'_tmp'; + } - $uploaded = $this->connection->put($remoteFile, $data); + + $uploaded = $this->connection->put($upload_remoteFile, $data); if (!$uploaded) { $this->cli->error(" ! Failed to upload {$fileBaseless}."); @@ -1199,7 +1206,18 @@ public function push($files, $localRevision = null) if (!$this->connection) { $this->cli->info(' * Connection lost, trying to reconnect...'); $this->connect($this->currentServerInfo); - $uploaded = $this->connection->put($remoteFile, $data); + $uploaded = $this->connection->put($upload_remoteFile, $data); + } + } + + if($uploaded) { + //Upload was successful lets + //If uploadRename lets rename on server to correct filename + if($this->servers[$this->currentServerName]['uploadRename']) { + + if(!$this->connection->getAdapter()->rename($upload_remoteFile, $remoteFile)) { + throw new \Exception("'{$remoteFile}' Rename failed."); + } } } diff --git a/src/plugins/FtpRename.php b/src/plugins/FtpRename.php new file mode 100644 index 0000000..2fd8df3 --- /dev/null +++ b/src/plugins/FtpRename.php @@ -0,0 +1,23 @@ +filesystem->getAdapter()->rename($path, $newpath); + + } +}