cleanup when storing compiled file
This commit is contained in:
parent
cdff8dded1
commit
c985cb5fd9
|
@ -41,20 +41,20 @@ abstract class BaseCompiler implements Responsable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function storeAs(string $directory, string $name, string $disk): void
|
||||
public function storeAs(string $directory, string $name, string $disk): string
|
||||
{
|
||||
$contents = $this->file->getContent();
|
||||
|
||||
Storage::disk($disk)->put($name, $contents);
|
||||
Storage::disk($disk)->put($directory.'/'.$name, $contents);
|
||||
|
||||
$this->cleanup();
|
||||
|
||||
return $directory.'/'.$name;
|
||||
}
|
||||
|
||||
public function storeIn(string $directory, string $disk): string
|
||||
{
|
||||
$contents = $this->file->getContent();
|
||||
|
||||
Storage::disk($disk)->put($directory.'/'.$this->file->getFilename(), $contents);
|
||||
|
||||
return $this->file->getFilename();
|
||||
return $this->storeAs($directory, $this->file->getFilename(), $disk);
|
||||
}
|
||||
|
||||
public function toResponse($request)
|
||||
|
@ -90,4 +90,9 @@ abstract class BaseCompiler implements Responsable
|
|||
$document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()),
|
||||
])->implode(' && ');
|
||||
}
|
||||
|
||||
private function cleanup(): void
|
||||
{
|
||||
exec('rm -R '.$this->file->getPath());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue