mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 05:24:25 +08:00
Generate a new revision string when files change
This commit is contained in:
parent
840bbfd995
commit
d4ee1d87a5
@ -26,10 +26,7 @@ class RevisionCompiler implements CompilerInterface
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
if (! ($revision = $this->getRevision())) {
|
||||
$revision = Str::quickRandom();
|
||||
$this->putRevision($revision);
|
||||
}
|
||||
$revision = $this->getRevision();
|
||||
|
||||
$lastModTime = 0;
|
||||
foreach ($this->files as $file) {
|
||||
@ -39,8 +36,16 @@ class RevisionCompiler implements CompilerInterface
|
||||
$ext = pathinfo($this->filename, PATHINFO_EXTENSION);
|
||||
$file = $this->path.'/'.substr_replace($this->filename, '-'.$revision, -strlen($ext) - 1, 0);
|
||||
|
||||
if (! file_exists($file)
|
||||
if (! ($exists = file_exists($file))
|
||||
|| filemtime($file) < $lastModTime) {
|
||||
|
||||
if ($exists) {
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
$revision = Str::quickRandom();
|
||||
$this->putRevision($revision);
|
||||
$file = $this->path.'/'.substr_replace($this->filename, '-'.$revision, -strlen($ext) - 1, 0);
|
||||
file_put_contents($file, $this->compile());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user