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