return refresh keys if item is cached

Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
Kiss Miklos
2022-08-26 09:33:35 +02:00
parent 408354d1f5
commit 4eebdfb0cc
2 changed files with 16 additions and 13 deletions
@@ -145,20 +145,22 @@ export class DefaultProcessingDatabase implements ProcessingDatabase {
BATCH_SIZE,
);
// Delete old refresh keys
await tx<DbRefreshKeysRow>('refresh_keys')
.where({ entity_id: id })
.delete();
if (refreshKeys && refreshKeys.length > 0) {
// Delete old refresh keys
await tx<DbRefreshKeysRow>('refresh_keys')
.where({ entity_id: id })
.delete();
// Insert the refresh keys for the processed entity
await tx.batchInsert(
'refresh_keys',
refreshKeys.map(k => ({
entity_id: id,
key: k.key,
})),
BATCH_SIZE,
);
// Insert the refresh keys for the processed entity
await tx.batchInsert(
'refresh_keys',
refreshKeys.map(k => ({
entity_id: id,
key: k.key,
})),
BATCH_SIZE,
);
}
return {
previous: {
@@ -102,6 +102,7 @@ export class UrlReaderProcessor implements CatalogProcessor {
for (const parseResult of cacheItem.value) {
emit(parseResult);
}
emit(processingResult.refresh(`${location.type}:${location.target}`));
} else if (error.name === 'NotFoundError') {
if (!optional) {
emit(processingResult.notFoundError(location, message));