some changes that were long overdue

This commit is contained in:
Matthew Exon 2023-12-26 15:14:35 +01:00
parent 511271ba37
commit f783b4857d

View file

@ -125,12 +125,12 @@ function retriever_addon_admin_post () {
* @brief Cron jobs for retriever plugin * @brief Cron jobs for retriever plugin
*/ */
function retriever_cron() { function retriever_cron() {
$downloads_per_cron = DI::config()->get('retriever', 'downloads_per_cron'); $downloads_per_cron = DI::config()->get('retriever', 'downloads_per_cron', '100');
// Do this first, otherwise it can interfere with retriever_retrieve_items // Do this first, otherwise it can interfere with retriever_retrieve_items
retriever_clean_up_completed_resources($downloads_per_cron); retriever_clean_up_completed_resources((int)$downloads_per_cron);
retriever_retrieve_items($downloads_per_cron); retriever_retrieve_items((int)$downloads_per_cron);
retriever_tidy(); retriever_tidy();
} }
@ -476,7 +476,7 @@ function add_retriever_resource(string $url, string $uid, string $cid, bool $bin
return $resource; return $resource;
} }
DBA::insert('retriever_resource', ['item-uid' => intval($uid), 'contact-id' => intval($cid), 'type' => $type, 'binary' => ($binary ? 1 : 0), 'url' => $url, 'completed' => DateTimeFormat::utcNow(), 'data' => $data]); DBA::insert('retriever_resource', ['item-uid' => intval($uid), 'contact-id' => intval($cid), 'type' => $type, 'binary' => ($binary ? 1 : 0), 'url' => $url, 'completed' => DateTimeFormat::utcNow(), 'data' => $data, 'redirect-url' => '']);
$resource = DBA::selectFirst('retriever_resource', [], ['url' => $url, 'item-uid' => intval($uid), 'contact-id' => intval($cid)]); $resource = DBA::selectFirst('retriever_resource', [], ['url' => $url, 'item-uid' => intval($uid), 'contact-id' => intval($cid)]);
if ($resource) { if ($resource) {
retriever_resource_completed($resource); retriever_resource_completed($resource);
@ -495,7 +495,7 @@ function add_retriever_resource(string $url, string $uid, string $cid, bool $bin
return $resource; return $resource;
} }
DBA::insert('retriever_resource', ['item-uid' => intval($uid), 'contact-id' => intval($cid), 'binary' => ($binary ? 1 : 0), 'url' => $url]); DBA::insert('retriever_resource', ['item-uid' => intval($uid), 'contact-id' => intval($cid), 'binary' => ($binary ? 1 : 0), 'url' => $url, 'redirect-url' => '']);
return DBA::selectFirst('retriever_resource', [], ['url' => $url, 'item-uid' => intval($uid), 'contact-id' => intval($cid)]); return DBA::selectFirst('retriever_resource', [], ['url' => $url, 'item-uid' => intval($uid), 'contact-id' => intval($cid)]);
} }