update to laravel 9

This commit is contained in:
xiaomlove
2022-03-31 22:22:04 +08:00
parent 09350c06e2
commit 5f6b3ceb53
30 changed files with 3420 additions and 2517 deletions
+22
View File
@@ -696,6 +696,16 @@ class SearchRepository extends BaseRepository
return true;
}
$log = "[UPDATE_TORRENT]: $id";
$result = $this->getTorrent($id);
if ($this->isEsResponseError($result)) {
do_log("$log, fail: " . nexus_json_encode($result), 'error');
return false;
}
if ($result['found'] === false) {
do_log("$log, not exists, do insert");
return $this->addTorrent($id);
}
$baseFields = $this->getTorrentBaseFields();
$torrent = Torrent::query()->findOrFail($id, array_merge(['id'], $baseFields));
$data = $this->buildTorrentBody($torrent);
@@ -733,6 +743,18 @@ class SearchRepository extends BaseRepository
return $this->syncTorrentTags($torrent);
}
public function getTorrent($id): callable|bool|array
{
if (!$this->enabled) {
return false;
}
$params = [
'index' => self::INDEX_NAME,
'id' => $this->getTorrentId($id),
];
return $this->es->get($params);
}
public function deleteTorrent(int $id): bool
{
if (!$this->enabled) {