Set uuid string for temporary filename
This commit is contained in:
parent
6d88ccb8f1
commit
5a5f1756e1
|
@ -21,7 +21,7 @@ abstract class BaseCompiler implements Responsable
|
||||||
|
|
||||||
if ($document->template()) {
|
if ($document->template()) {
|
||||||
$templatePath = $document->template()->fullPath();
|
$templatePath = $document->template()->fullPath();
|
||||||
exec('rsync -av '.escapeshellarg($templatePath).'/ '.escapeshellarg($this->file->getPath()));
|
exec('rsync -av ' . escapeshellarg($templatePath) . '/ ' . escapeshellarg($this->file->getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
exec($this->command($document), $output, $returnVar);
|
exec($this->command($document), $output, $returnVar);
|
||||||
|
@ -45,11 +45,11 @@ abstract class BaseCompiler implements Responsable
|
||||||
{
|
{
|
||||||
$contents = $this->file->getContent();
|
$contents = $this->file->getContent();
|
||||||
|
|
||||||
Storage::disk($disk)->put($directory.'/'.$name, $contents);
|
Storage::disk($disk)->put($directory . '/' . $name, $contents);
|
||||||
|
|
||||||
$this->cleanup();
|
$this->cleanup();
|
||||||
|
|
||||||
return $directory.'/'.$name;
|
return $directory . '/' . $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storeIn(string $directory, string $disk): string
|
public function storeIn(string $directory, string $disk): string
|
||||||
|
@ -72,9 +72,9 @@ abstract class BaseCompiler implements Responsable
|
||||||
|
|
||||||
protected function prepareForCompilation(Document $document): void
|
protected function prepareForCompilation(Document $document): void
|
||||||
{
|
{
|
||||||
$workDir = '/tmp/'.Str::random(32);
|
$workDir = '/tmp/' . Str::uuid()->toString();
|
||||||
mkdir($workDir, 0777, true);
|
mkdir($workDir, 0777, true);
|
||||||
$this->file = new File($workDir.'/'.$document->compiledFilename(), false);
|
$this->file = new File($workDir . '/' . $document->compiledFilename(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function refreshFile(): void
|
private function refreshFile(): void
|
||||||
|
@ -85,14 +85,14 @@ abstract class BaseCompiler implements Responsable
|
||||||
private function command(Document $document): string
|
private function command(Document $document): string
|
||||||
{
|
{
|
||||||
return collect([
|
return collect([
|
||||||
'cd '.escapeshellarg($this->file->getPath()),
|
'cd ' . escapeshellarg($this->file->getPath()),
|
||||||
$document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()),
|
$document->getEngine()->binary() . ' --halt-on-error ' . escapeshellarg($document->filename()),
|
||||||
$document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()),
|
$document->getEngine()->binary() . ' --halt-on-error ' . escapeshellarg($document->filename()),
|
||||||
])->implode(' && ');
|
])->implode(' && ');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cleanup(): void
|
private function cleanup(): void
|
||||||
{
|
{
|
||||||
exec('rm -R '.$this->file->getPath());
|
exec('rm -R ' . $this->file->getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue