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;
|
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();
|
$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
|
public function storeIn(string $directory, string $disk): string
|
||||||
{
|
{
|
||||||
$contents = $this->file->getContent();
|
return $this->storeAs($directory, $this->file->getFilename(), $disk);
|
||||||
|
|
||||||
Storage::disk($disk)->put($directory.'/'.$this->file->getFilename(), $contents);
|
|
||||||
|
|
||||||
return $this->file->getFilename();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toResponse($request)
|
public function toResponse($request)
|
||||||
|
@ -90,4 +90,9 @@ abstract class BaseCompiler implements Responsable
|
||||||
$document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()),
|
$document->getEngine()->binary().' --halt-on-error '.escapeshellarg($document->filename()),
|
||||||
])->implode(' && ');
|
])->implode(' && ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function cleanup(): void
|
||||||
|
{
|
||||||
|
exec('rm -R '.$this->file->getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue