Finish Tar archive builder

modifié:         core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php
	modifié:         core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php
	nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/bad_formatted.tar
	nouveau fichier: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/well_formatted.tar
	modifié:         core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php
This commit is contained in:
Benjamin Perche
2014-07-03 14:51:20 +02:00
parent c9b485d3e5
commit 880626e4de
3 changed files with 187 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder;
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException;
<<<<<<< HEAD
<<<<<<< HEAD
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator;
@@ -23,6 +24,12 @@ use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator;
>>>>>>> Finish implementing and testing zip
=======
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\FileNotReadableException;
>>>>>>> Finish Tar archive builder
use Thelia\Log\Tlog;
use Thelia\Tools\FileDownload\FileDownloaderInterface;
@@ -77,8 +84,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
$this->compression = $compressionType;
}
<<<<<<< HEAD
/**
>>>>>>> Finish implementing and testing zip
=======
>>>>>>> Finish Tar archive builder
public function __destruct()
{
if ($this->tar instanceof \PharData) {
@@ -86,6 +97,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
unlink($this->cacheFile);
}
}
<<<<<<< HEAD
<<<<<<< HEAD
}
@@ -96,6 +108,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
* @param bool $isOnline
=======
}*/
=======
}
>>>>>>> Finish Tar archive builder
/**
* @param string $filePath It is the path to access the file.
@@ -147,13 +162,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
$this->tar->addFile($filePath, $name);
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> Finish Tar archive builder
/**
* And clear the download temp file
*/
unlink($fileDownloadCache);
<<<<<<< HEAD
=======
>>>>>>> Finish implementing and testing zip
=======
>>>>>>> Finish Tar archive builder
return $this;
}
@@ -371,9 +392,32 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
=======
public function buildArchiveResponse()
{
$this->tar->setMetadata("comment", "Generated by Thelia v" . Thelia::THELIA_VERSION);
$this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION);
if (!is_file($this->cacheFile)) {
$this->throwFileNotFound($this->cacheFile);
}
if (!is_readable($this->cacheFile)) {
throw new FileNotReadableException(
$this->translator->trans(
"The file %file is not readable",
[
"%file" => $this->cacheFile
]
)
);
}
$content = file_get_contents($this->cacheFile);
return new Response(
$content,
200,
[
"Content-Type" => $this->getMimeType(),
]
);
}
/**