From cf84f8df0afddd8076f803f9defaebb783e7c86e Mon Sep 17 00:00:00 2001 From: gioelecerati Date: Mon, 20 Nov 2023 14:00:13 +0100 Subject: [PATCH] asset: never reprocess assets when duplicated --- packages/api/src/store/asset-table.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/api/src/store/asset-table.ts b/packages/api/src/store/asset-table.ts index ebf48d89f9..648402b79a 100644 --- a/packages/api/src/store/asset-table.ts +++ b/packages/api/src/store/asset-table.ts @@ -3,8 +3,6 @@ import { Asset, Task, User } from "../schema/types"; import Table from "./table"; import { QueryOptions, WithID } from "./types"; -const DUPLICATE_ASSETS_THRESHOLD = 15 * 60 * 1000; // 15 mins - export const taskOutputToIpfsStorage = ( out: Task["output"]["export"]["ipfs"] ): Omit => @@ -123,14 +121,12 @@ export default class AssetTable extends Table> { url: string, userId: string ): Promise> { - const createdAfter = Date.now() - DUPLICATE_ASSETS_THRESHOLD; const query = [ sql`asset.data->>'deleted' IS NULL`, sql`asset.data->>'userId' = ${userId}`, sql`asset.data->'source'->>'type' = 'url'`, sql`asset.data->'source'->>'url' = ${url}`, - sql`asset.data->'status'->>'phase' IN ('waiting', 'processing')`, - sql`coalesce((asset.data->>'createdAt')::bigint, 0) > ${createdAfter}`, + sql`asset.data->'status'->>'phase' IN ('waiting', 'processing', 'ready')`, ]; const [assets] = await this.find(query, { limit: 1 }); return assets?.length > 0 ? assets[0] : null;