/**
  * Will copy the file from the source to the destination.
  *
  * If this is a local to local copy, and the destination is the same as the source,
  * it won't be copied (since it's already at it's destination).
  *
  * @param string    $sourceDumpFile     Path to source file.
  * @param Machine   $dest
  * @param string|null $localTmp         If this is a remote to remote copy, pass the localTmp
  *
  * @throws \InvalidArgumentException    If the copy failed because of an invalid parameter.
  *
  * @return string|bool  False if failed, otherwise the path to the dump file on the destination.
  */
 public function copyDumpFile($sourceDumpFile, Machine $dest, $localTmp = null)
 {
     $destDumpFile = $dest->generateDumpFilePath();
     // don't copy if this is a local to local sync, and the source and dest are
     // the same (it's already where we want it to be)
     if (!$this->getOptions()->isLocal() || !$dest->getOptions()->isLocal() || $sourceDumpFile != $destDumpFile) {
         $copier = new Copier($this->options->getSsh(), $dest->getOptions()->getSsh(), $localTmp);
         try {
             if (!$copier->copy($sourceDumpFile, $destDumpFile)) {
                 return false;
             }
         } catch (\UnexpectedValueException $e) {
             throw new \InvalidArgumentException($e->getMessage());
         } catch (\InvalidArgumentException $e) {
             throw new \InvalidArgumentException($e->getMessage());
         }
     }
     return $destDumpFile;
 }
Exemple #2
0
 public function testLocalToRemoteFail()
 {
     $copier = new Copier(null, $this->destSsh);
     $localFile = $this->getLocalPath("hopefully/not/here/blah.txt");
     $destFile = $this->getDestPath(basename($localFile));
     $success = $copier->copy($localFile, $destFile);
     $this->assertDestFileDoesntExist($destFile);
     $this->assertFalse($success);
 }