From 6a5d38a797bf067002f2996c1d5f31330b73ce05 Mon Sep 17 00:00:00 2001 From: Viren070 Date: Thu, 20 Nov 2025 21:25:22 +0000 Subject: [PATCH] fix: only use file info store when length exceeds certain amount --- packages/core/src/debrid/utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/core/src/debrid/utils.ts b/packages/core/src/debrid/utils.ts index 2aedd992..1d768742 100644 --- a/packages/core/src/debrid/utils.ts +++ b/packages/core/src/debrid/utils.ts @@ -498,10 +498,14 @@ export function generatePlaybackUrl( filename?: string ): string { const fileInfoCache = fileInfoStore(); - let fileInfoId: string | undefined; - if (fileInfoCache) { - fileInfoId = getSimpleTextHash(JSON.stringify(fileInfo)); - fileInfoCache.set(fileInfoId, fileInfo, Env.BUILTIN_PLAYBACK_LINK_VALIDITY); + let fileInfoStr: string = toUrlSafeBase64(JSON.stringify(fileInfo)); + if (fileInfoCache && fileInfoStr.length > 500) { + fileInfoStr = getSimpleTextHash(JSON.stringify(fileInfo)); + fileInfoCache.set( + fileInfoStr, + fileInfo, + Env.BUILTIN_PLAYBACK_LINK_VALIDITY + ); } - return `${Env.BASE_URL}/api/v1/debrid/playback/${encryptedStoreAuth}/${fileInfoId ?? toUrlSafeBase64(JSON.stringify(fileInfo))}/${metadataId}/${encodeURIComponent(filename ?? title ?? 'unknown')}`; + return `${Env.BASE_URL}/api/v1/debrid/playback/${encryptedStoreAuth}/${fileInfoStr}/${metadataId}/${encodeURIComponent(filename ?? title ?? 'unknown')}`; }