1
0

Avoid some disk writes with checksums

This commit is contained in:
Richard Dern 2024-05-09 23:22:40 +02:00
parent 66356bfd78
commit bb0fb1dadd

View File

@ -189,6 +189,18 @@ private function renderFeed(): self
foreach ($result as $path => $content) {
$this->output->write(sprintf('Rendering <info>%s</info> as feed... ', $path));
if ($this->targetDisk->exists($path)) {
$fileChecksum = $this->targetDisk->checksum($path);
$contentChecksum = md5($content);
if ($fileChecksum === $contentChecksum) {
$this->info('Not changed');
continue;
}
}
$this->targetDisk->put($path, $content);
$this->info('OK');
}
@ -230,6 +242,15 @@ private function handleBundle(Bundle $bundle, $progress)
$path = Str::finish($path, '/') . 'index.html';
}
if ($this->targetDisk->exists($path)) {
$fileChecksum = $this->targetDisk->checksum($path);
$contentChecksum = md5($content);
if ($fileChecksum !== $contentChecksum) {
continue;
}
}
$this->targetDisk->put($path, $content);
}
}