Ejemplo n.º 1
0
 public function work($json)
 {
     if (!isset($json['project'])) {
         return;
     }
     if (!isset($json['body']['current']) || !isset($json['body']['target'])) {
         return;
     }
     if (!isset($json['body']['current']['Major']) || !isset($json['body']['current']['Minor']) || !isset($json['body']['current']['Build'])) {
         return;
     }
     if (!isset($json['body']['target']['Major']) || !isset($json['body']['target']['Minor']) || !isset($json['body']['target']['Build'])) {
         return;
     }
     if (!projectExists($json['project'], $this->config)) {
         return;
     }
     $current = versionToString($json['body']['current']['Major'], $json['body']['current']['Minor'], $json['body']['current']['Build']);
     $target = versionToString($json['body']['target']['Major'], $json['body']['target']['Minor'], $json['body']['target']['Build']);
     $projects_dir = "./" . $this->config['projects_root'];
     $project_name = $json['project'];
     $project_dir = $projects_dir . DIRECTORY_SEPARATOR . $project_name;
     $versionDifference = array_reverse(versionsBetween($current, $target, $project_name, $this->config));
     $changed_files = array();
     foreach ($versionDifference as $vd) {
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($project_dir . DIRECTORY_SEPARATOR . $vd)) as $filename) {
             // filter out "." and ".."
             if ($filename->isDir()) {
                 continue;
             }
             $file = str_replace($project_dir . DIRECTORY_SEPARATOR . $vd, "", $filename->getPath());
             $file = $file . DIRECTORY_SEPARATOR . $filename->getFileName();
             if (startsWith($file, DIRECTORY_SEPARATOR)) {
                 $file = substr($file, 1);
             }
             if (!array_key_exists($file, $changed_files)) {
                 $changed_files[$file] = $filename->getSize();
             }
         }
     }
     $this->addBody("new_sizes", $changed_files);
 }
Ejemplo n.º 2
0
 public function work($json)
 {
     if (!isset($json['project'])) {
         return;
     }
     if (!isset($json['body']['version']) || !isset($json['body']['remote_path'])) {
         return;
     }
     if (!isset($json['body']['version']['Major']) || !isset($json['body']['version']['Minor']) || !isset($json['body']['version']['Build'])) {
         return;
     }
     $remote_path = $json['body']['remote_path'];
     $project = $json['project'];
     $version = versionToString($json['body']['version']['Major'], $json['body']['version']['Minor'], $json['body']['version']['Build']);
     if (!projectExists($project, $this->config) || !versionExists($version, $json['project'], $this->config)) {
         $this->error('NOT_FOUND');
         return;
     }
     $path_before_version = getPathToProject($project, $this->config) . DIRECTORY_SEPARATOR;
     $path_after_version = DIRECTORY_SEPARATOR . $remote_path;
     $file_path = $path_before_version . $version . $path_after_version;
     if (file_exists($file_path)) {
         $this->setResponseAsFile();
         $this->setContent(file_get_contents($file_path));
         return;
     } else {
         $lowerVersions = array_reverse(versionsLower($version, $project, $this->config));
         foreach ($lowerVersions as $v) {
             $newPath = $path_before_version . $v . $path_after_version;
             if (file_exists($newPath)) {
                 $this->setResponseAsFile();
                 $this->setContent(file_get_contents($newPath));
                 return;
             }
         }
         $this->error('NOT_FOUND');
         $this->addBody("path", $file_path);
         $this->addBody("rel", $remote_path);
     }
 }