diff --git a/app/Classes/Bundle.php b/app/Classes/Bundle.php index 82e8319..9632625 100644 --- a/app/Classes/Bundle.php +++ b/app/Classes/Bundle.php @@ -175,7 +175,7 @@ public function load(): void /** * Store all files of the bundle */ - public function save(): void + public function save(): bool { $attachmentsSaved = $this->saveAttachments(); $metadataSaved = $this->saveMetadata(); @@ -187,19 +187,24 @@ public function save(): void || $markdownSaved ) { $this->touch(); + + return true; } + + return false; } /** * Repair bundle */ - public function repair(): void + public function repair(): bool { $this->load(); $this->repairCover(); $this->lintMarkdown(); $this->repairAttachments(); - $this->save(); + + return $this->save(); } public function touch() diff --git a/app/Console/Commands/Bundle/Update.php b/app/Console/Commands/Bundle/Update.php index 750b6c3..c6c50dc 100644 --- a/app/Console/Commands/Bundle/Update.php +++ b/app/Console/Commands/Bundle/Update.php @@ -60,9 +60,13 @@ public function handle() continue; } - $updater->update(); + $result = $updater->update(); - $this->info('OK'); + if ($result) { + $this->info('OK'); + } else { + $this->comment('Update not needed'); + } } } } diff --git a/app/Services/BundleUpdaters/Updaters/CriticUpdater.php b/app/Services/BundleUpdaters/Updaters/CriticUpdater.php index a40b315..a353276 100644 --- a/app/Services/BundleUpdaters/Updaters/CriticUpdater.php +++ b/app/Services/BundleUpdaters/Updaters/CriticUpdater.php @@ -88,8 +88,15 @@ public function update() 'wikidata/links', ]); - $this->bundle->save(); - $this->bundle->repair(); + $saved = $this->bundle->save(); + + if ($saved) { + $this->bundle->repair(); + } else { + $saved = $this->bundle->repair(); + } + + return $saved; } /** diff --git a/app/Services/BundleUpdaters/Updaters/LegoUpdater.php b/app/Services/BundleUpdaters/Updaters/LegoUpdater.php index 7383a48..a5295a7 100644 --- a/app/Services/BundleUpdaters/Updaters/LegoUpdater.php +++ b/app/Services/BundleUpdaters/Updaters/LegoUpdater.php @@ -92,8 +92,15 @@ public function update() } } - $this->bundle->save(); - $this->bundle->repair(); + $saved = $this->bundle->save(); + + if ($saved) { + $this->bundle->repair(); + } else { + $saved = $this->bundle->repair(); + } + + return $saved; } /**