<commit_before><?php
namespace PhpBrew\Tasks;
use GetOptionKit\OptionResult;
use PhpBrew\Build;

/**
 * Task to download php distributions.
 */
class ExtractTask extends BaseTask
{

    /**
     * @param string $targetFilePath absolute file path
     */
    public function extract(Build $build, $targetFilePath, $extractDir = NULL)
    {
        // Unpack the tarball file
        if (!$extractDir) {
            $extractDir = dirname($targetFilePath);
        }

        $extractedDir = $extractDir . DIRECTORY_SEPARATOR . $build->getName();

        if ($build->getState() >= Build::STATE_EXTRACT && file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure') ) {
            $this->info("===> Distribution file was successfully extracted, skipping...");
            return $extractedDir;
        }

        // NOTICE: Always extract to prevent incomplete extraction
        $this->info("===> Extracting $targetFilePath to $extractedDir");
        system("tar -C $extractDir -xjf $targetFilePath", $ret);
        if ($ret != 0) {
            die('Extract failed.');
        }
        $build->setState(Build::STATE_EXTRACT);
        return $extractedDir;
        /*
         * XXX: unless we have a fast way to verify the extraction.
        if ($this->options->force || ! file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
            $this->info("===> Extracting $targetFilePath...");
            system("tar -C $dir -xjf $targetFilePath", $ret);
            if ($ret != 0) {
                die('Extract failed.');
            }
        } else {
            $this->info("Found existing $extractedDir, Skip extracting.");
        }
        */
    }
}
<commit_msg>Fixed the source tarball extraction task.<commit_after><?php
namespace PhpBrew\Tasks;
use GetOptionKit\OptionResult;
use PhpBrew\Config;
use PhpBrew\Build;

/**
 * Task to download php distributions.
 */
class ExtractTask extends BaseTask
{

    /**
     * Unpacks the source tarball file.
     *
     * @param string $targetFilePath absolute file path
     */
    public function extract(Build $build, $targetFilePath, $extractDir = NULL)
    {
        $extractDirTemp = Config::getTempFileDir();
        if (!$extractDir) {
            $extractDir = dirname($targetFilePath);
        }

        $extractedDirTemp = $extractDirTemp . DIRECTORY_SEPARATOR . preg_replace('#\.tar\.(gz|bz2)$#', '', basename($targetFilePath));
        $extractedDir     = $extractDir . DIRECTORY_SEPARATOR . $build->getName();

        if ($build->getState() >= Build::STATE_EXTRACT && file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure') ) {
            $this->info("===> Distribution file was successfully extracted, skipping...");
            return $extractedDir;
        }

        // NOTICE: Always extract to prevent incomplete extraction
        $this->info("===> Extracting $targetFilePath to $extractedDirTemp");
        system("tar -C $extractDirTemp -xjf $targetFilePath", $ret);
        if ($ret != 0) {
            die('Extract failed.');
        }

        $this->info("===> Moving $extractedDirTemp to $extractedDir");
        rename ($extractedDirTemp, $extractedDir);

        $build->setState(Build::STATE_EXTRACT);
        return $extractedDir;
        /*
         * XXX: unless we have a fast way to verify the extraction.
        if ($this->options->force || ! file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
            $this->info("===> Extracting $targetFilePath...");
            system("tar -C $dir -xjf $targetFilePath", $ret);
            if ($ret != 0) {
                die('Extract failed.');
            }
        } else {
            $this->info("Found existing $extractedDir, Skip extracting.");
        }
        */
    }
}

{'fraction_non_alphanumeric': 0.13962163602451372, 'fraction_numerical': 0.001332267519317879, 'mean_word_length': 2.394213381555154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6254577', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1036, 'n_words': 259}