Fixed: delete merged data

This commit is contained in:
Philipp Lang 2023-12-11 16:26:34 +01:00
parent bbab104f7e
commit 287ba39dc0
1 changed files with 4 additions and 3 deletions

View File

@ -53,10 +53,11 @@ abstract class BaseCompiler implements Responsable
*/ */
public function merge(array $documents): self public function merge(array $documents): self
{ {
$outfile = '/tmp/' . Str::uuid()->toString() . '.pdf'; $outfile = new File('/tmp/' . Str::uuid()->toString() . '/' . Str::uuid()->toString() . '.pdf', false);
mkdir($outfile->getPath());
$paths = array_map(fn ($document) => static::compile($document)->getPath(), $documents); $paths = array_map(fn ($document) => static::compile($document)->getPath(), $documents);
$command = collect([ $command = collect([
'pdfjam --nup 1x1 --outfile ' . $outfile, 'pdfjam --nup 1x1 --outfile ' . $outfile->getPathname(),
...array_map(fn ($path) => escapeshellarg($path), $paths), ...array_map(fn ($path) => escapeshellarg($path), $paths),
])->implode(' '); ])->implode(' ');
@ -71,7 +72,7 @@ abstract class BaseCompiler implements Responsable
throw (new CompilerException('Compilation failed.'))->setOutput($output); throw (new CompilerException('Compilation failed.'))->setOutput($output);
} }
return static::fromFile($outfile); return static::fromFile($outfile->getPathname());
} }
public function storeAs(string $directory, string $name, string $disk): string public function storeAs(string $directory, string $name, string $disk): string