Ejemplo n.º 1
0
 /**
  * @return same result with _downloadUpgradePackage but getting information from local repo
  */
 function _downloadUpgradePackageLocal($product, $upgradeVersion)
 {
     @set_time_limit(0);
     $FileSystemHelper = new FileSystemHelper();
     if ($product->version == $upgradeVersion) {
         jaucRaiseMessage("UpdaterService: cannot upgrade to same version", true);
         return false;
     }
     if (!($productDir = $this->getLocalVersionsPath($product))) {
         return false;
     }
     //
     $newVerDir = $productDir . $upgradeVersion . '/';
     if (!JFolder::exists($newVerDir)) {
         return false;
     }
     $vUpgrade = new stdClass();
     $vUpgrade->crc = $this->getVersionChecksum($newVerDir);
     //
     $orgVerDir = $productDir . $product->version . '/';
     if (JFolder::exists($orgVerDir)) {
         $vServer = new stdClass();
         $vServer->crc = $this->getVersionChecksum($orgVerDir);
     }
     //
     $pro = new jaProducts($product, $this->config, true);
     $oldPro = $pro->getFullInfo();
     //
     $pathPackageStore = $this->getLocalPatchPath($product);
     $package = sprintf("%s_%s_%s.zip", $product->extKey, $product->version, $upgradeVersion);
     $package = $pathPackageStore . $package;
     if (!isset($vServer)) {
         //clear cached package file
         if (JFile::exists($package)) {
             JFile::delete($package);
         }
     }
     if (!JFile::exists($package)) {
         $compare = new jaCompareTool();
         if (isset($vServer)) {
             $vResult = $compare->checkToBuildUpgradePackage($vServer, $vUpgrade);
         } else {
             $vResult = $compare->checkToBuildUpgradePackage($oldPro, $vUpgrade);
         }
         $tmpDir = $FileSystemHelper->tmpDir(null, 'ja', 0755);
         $tmpDir = $tmpDir . $oldPro->extKey . '/';
         if (JFolder::create($tmpDir, 0755) === false) {
             jaucRaiseMessage("UpdaterService: cannot build upgrade package", true);
             return false;
         }
         $infoFile = $tmpDir . "jaupdater.info.json";
         JFile::write($infoFile, json_encode($vResult));
         //echo $tmpDir;
         $this->_buildUpgradePackage($newVerDir, $tmpDir, $vResult);
         ArchiveHelper::zip($package, $tmpDir, true);
     }
     return $package;
 }
Ejemplo n.º 2
0
 private function _getUpgradePackage($oldPro, $newVersion, $refresh = false)
 {
     if ($oldPro->version == $newVersion) {
         $this->doResponse("Cannot upgrade if you are using this version", true);
     }
     $pathPackageStore = $this->config->get("UPKG_LOCATION") . DS;
     $package = sprintf("%s_%s_%s.zip", $oldPro->extKey, $oldPro->version, $newVersion);
     $package = $pathPackageStore . $package;
     if (!is_file($package) || $refresh) {
         //build package
         $vServer = $this->getProduct($oldPro);
         $newPro = $oldPro;
         $newPro->version = $newVersion;
         $vUpgrade = $this->getProduct($newPro);
         $compare = new jaCompareTool();
         if ($vServer !== false) {
             $savePackage = true;
             $vResult = $compare->checkToBuildUpgradePackage($vServer, $vUpgrade);
         } else {
             //if not found original version on server
             //the system will build upgrade package from user' version and new version
             //but this package will not be stored on server
             $savePackage = false;
             $vResult = $compare->checkToBuildUpgradePackage($oldPro, $vUpgrade);
             //store package to tmp folder
             $packageName = basename($package);
             $storeDir = FileSystemHelper::tmpDir(null, 'ja', 0777);
             $package = $storeDir . $packageName;
         }
         //$this->doResponse(print_r(scandir($vUpgrade->getLocation()), 1) . "---COMPARE_OBJECT:" . print_r($vResult, 1), true);
         $tmpDir = FileSystemHelper::tmpDir(null, 'ja', 0777);
         $tmpDir = $tmpDir . $oldPro->extKey . DS;
         if (mkdir($tmpDir, 0777) === false) {
             $this->doResponse("Cannot build upgrade package", true);
         }
         $infoFile = $tmpDir . "jaupdater.info.json";
         $fp = fopen($infoFile, 'wb');
         fwrite($fp, json_encode($vResult));
         fclose($fp);
         $this->_buildUpgradePackage($vUpgrade->getLocation(), $tmpDir, $vResult);
         ArchiveHelper::zip($package, $tmpDir, true);
     }
     return $package;
 }