Fix FileDownloader test

modifié:         core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php
	modifié:         core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php
	modifié:         core/lib/Thelia/Tools/FileDownload/FileDownloader.php
	modifié:         core/lib/Thelia/Tools/URL.php
This commit is contained in:
Benjamin Perche
2014-07-03 14:20:31 +02:00
parent 9e66c4759a
commit 4b78f23fa3
4 changed files with 87 additions and 5 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;
use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator;
use Thelia\Log\Tlog;
use Thelia\Tools\FileDownload\FileDownloaderInterface;
@@ -202,7 +203,24 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
*/
public function getFileContent($pathToFile)
{
$pathToFile = $this->formatFilePath($pathToFile);
if (!$this->hasFile($pathToFile)) {
$this->throwFileNotFound($pathToFile);
}
/** @var \PharFileInfo $fileInfo*/
$fileInfo = $this->tar[$pathToFile];
/** @var \SplFileObject $file */
$file = $fileInfo->openFile();
$content = "";
while (false !== ($char = $file->fgetc())) {
$content .= $char;
}
return $content;
}
@@ -239,6 +257,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
*/
public function buildArchiveResponse()
{
$this->tar->setMetadata("comment", "Generated by Thelia v" . Thelia::THELIA_VERSION);
}
@@ -267,8 +287,8 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
$instance->setFileDownloader($fileDownloader);
}
$instance->setCacheFile($instance->getCacheFile())
->copyFile($pathToArchive, $isOnline);
$instance->setCacheFile($instance->generateCacheFile($environment))
->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
/**
* This throws TarArchiveBuilderException if