From 5a5f1756e164f112d0dd8d470356458de2071a05 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Wed, 29 Nov 2023 13:03:37 +0100 Subject: [PATCH] Set uuid string for temporary filename --- src/BaseCompiler.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BaseCompiler.php b/src/BaseCompiler.php index 8e96d53..379ae6c 100644 --- a/src/BaseCompiler.php +++ b/src/BaseCompiler.php @@ -21,7 +21,7 @@ abstract class BaseCompiler implements Responsable if ($document->template()) { $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); @@ -45,11 +45,11 @@ abstract class BaseCompiler implements Responsable { $contents = $this->file->getContent(); - Storage::disk($disk)->put($directory.'/'.$name, $contents); + Storage::disk($disk)->put($directory . '/' . $name, $contents); $this->cleanup(); - return $directory.'/'.$name; + return $directory . '/' . $name; } public function storeIn(string $directory, string $disk): string @@ -72,9 +72,9 @@ abstract class BaseCompiler implements Responsable protected function prepareForCompilation(Document $document): void { - $workDir = '/tmp/'.Str::random(32); + $workDir = '/tmp/' . Str::uuid()->toString(); mkdir($workDir, 0777, true); - $this->file = new File($workDir.'/'.$document->compiledFilename(), false); + $this->file = new File($workDir . '/' . $document->compiledFilename(), false); } private function refreshFile(): void @@ -85,14 +85,14 @@ abstract class BaseCompiler implements Responsable private function command(Document $document): string { return collect([ - 'cd '.escapeshellarg($this->file->getPath()), - $document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()), - $document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()), + 'cd ' . escapeshellarg($this->file->getPath()), + $document->getEngine()->binary() . ' --halt-on-error ' . escapeshellarg($document->filename()), + $document->getEngine()->binary() . ' --halt-on-error ' . escapeshellarg($document->filename()), ])->implode(' && '); } private function cleanup(): void { - exec('rm -R '.$this->file->getPath()); + exec('rm -R ' . $this->file->getPath()); } }