mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-20 17:37:23 +08:00
update to laravel 9
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user