mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 18:19:27 +01:00
add caching & better error handling to update checking
This commit is contained in:
parent
4df52c21fa
commit
4db0702970
@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Contracts\Plugins\HasPluginSettings;
|
use App\Contracts\Plugins\HasPluginSettings;
|
||||||
use App\Enums\PluginStatus;
|
use App\Enums\PluginStatus;
|
||||||
|
use Exception;
|
||||||
use Filament\Forms\Components\Component;
|
use Filament\Forms\Components\Component;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
@ -197,13 +198,19 @@ class Plugin extends Model implements HasPluginSettings
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var array<string, array{version: string, download_url: string}> */
|
return cache()->remember("plugins.$this->id.update", now()->addHour(), function () use ($panelVersion) {
|
||||||
$updateData = file_get_contents($this->update_url);
|
try {
|
||||||
if ($updateData[$panelVersion]) {
|
/** @var array<string, array{version: string, download_url: string}> */
|
||||||
return version_compare($updateData[$panelVersion]['version'], $this->version, '>');
|
$updateData = file_get_contents($this->update_url);
|
||||||
}
|
if ($updateData[$panelVersion]) {
|
||||||
|
return version_compare($updateData[$panelVersion]['version'], $this->version, '>');
|
||||||
|
}
|
||||||
|
} catch (Exception $exception) {
|
||||||
|
report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasSettings(): bool
|
public function hasSettings(): bool
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user