mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
do not retry if find_thumbnail job fails
This commit is contained in:
parent
e54c691c09
commit
4c765378e3
4 changed files with 21 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
findLibraryItemById,
|
||||
updateLibraryItem,
|
||||
} from '../services/library_item'
|
||||
import { createImageProxyUrl, createThumbnailUrl } from '../utils/imageproxy'
|
||||
import { logger } from '../utils/logger'
|
||||
|
||||
interface Data {
|
||||
|
|
@ -139,8 +140,9 @@ export const findThumbnail = async (data: Data) => {
|
|||
const thumbnail = item.thumbnail
|
||||
if (thumbnail) {
|
||||
logger.info('thumbnail already set')
|
||||
const proxyUrl = createThumbnailUrl(thumbnail)
|
||||
// pre-cache thumbnail first if exists
|
||||
const image = await fetchImage(thumbnail)
|
||||
const image = await fetchImage(proxyUrl)
|
||||
if (!image) {
|
||||
logger.info('thumbnail image not found')
|
||||
item.thumbnail = undefined
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { LibraryItem, LibraryItemState } from '../entity/library_item'
|
||||
import { enqueueThumbnailTask } from '../utils/createTask'
|
||||
import { enqueueThumbnailJob } from '../utils/createTask'
|
||||
import {
|
||||
cleanUrl,
|
||||
generateSlug,
|
||||
|
|
@ -132,12 +132,14 @@ export const saveEmail = async (
|
|||
|
||||
await updateReceivedEmail(input.receivedEmailId, 'article', input.userId)
|
||||
|
||||
// create a task to update thumbnail and pre-cache all images
|
||||
try {
|
||||
const taskId = await enqueueThumbnailTask(input.userId, slug)
|
||||
logger.info('Created thumbnail task', { taskId })
|
||||
} catch (e) {
|
||||
logger.error('Failed to create thumbnail task', e)
|
||||
if (!newLibraryItem.thumbnail) {
|
||||
// create a task to update thumbnail and pre-cache all images
|
||||
try {
|
||||
const job = await enqueueThumbnailJob(input.userId, newLibraryItem.id)
|
||||
logger.info('Created thumbnail job', { taskId: job })
|
||||
} catch (e) {
|
||||
logger.error('Failed to create thumbnail job', e)
|
||||
}
|
||||
}
|
||||
|
||||
return newLibraryItem
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
SaveResult,
|
||||
} from '../generated/graphql'
|
||||
import { authTrx } from '../repository'
|
||||
import { enqueueThumbnailTask } from '../utils/createTask'
|
||||
import { enqueueThumbnailJob } from '../utils/createTask'
|
||||
import {
|
||||
cleanUrl,
|
||||
generateSlug,
|
||||
|
|
@ -170,10 +170,10 @@ export const savePage = async (
|
|||
if (!isImported && !parseResult.parsedContent?.previewImage) {
|
||||
try {
|
||||
// create a task to update thumbnail and pre-cache all images
|
||||
const job = await enqueueThumbnailTask(user.id, clientRequestId)
|
||||
logger.info('Created thumbnail task', { job })
|
||||
const job = await enqueueThumbnailJob(user.id, clientRequestId)
|
||||
logger.info('Created thumbnail job', { job })
|
||||
} catch (e) {
|
||||
logger.error('Failed to create thumbnail task', e)
|
||||
logger.error('Failed to enqueue thumbnail job', e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ import {
|
|||
ArticleSavingRequestStatus,
|
||||
CreateLabelInput,
|
||||
} from '../generated/graphql'
|
||||
import { THUMBNAIL_JOB } from '../jobs/find_thumbnail'
|
||||
import { queueRSSRefreshFeedJob } from '../jobs/rss/refreshAllFeeds'
|
||||
import { getBackendQueue } from '../queue-processor'
|
||||
import { redisDataSource } from '../redis_data_source'
|
||||
import { signFeatureToken } from '../services/features'
|
||||
import { generateVerificationToken, OmnivoreAuthorizationHeader } from './auth'
|
||||
import { OmnivoreAuthorizationHeader } from './auth'
|
||||
import { CreateTaskError } from './errors'
|
||||
import { stringToHash } from './helpers'
|
||||
import { logger } from './logger'
|
||||
|
|
@ -579,7 +581,7 @@ export const enqueueExportToIntegration = async (
|
|||
return createdTasks[0].name
|
||||
}
|
||||
|
||||
export const enqueueThumbnailTask = async (
|
||||
export const enqueueThumbnailJob = async (
|
||||
userId: string,
|
||||
libraryItemId: string
|
||||
) => {
|
||||
|
|
@ -593,6 +595,7 @@ export const enqueueThumbnailTask = async (
|
|||
}
|
||||
return queue.add(THUMBNAIL_JOB, payload, {
|
||||
priority: 100,
|
||||
attempts: 1,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue