X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fredis.ts;h=46617b07e4ac6405978d9249b1c1f8681b30f9c7;hb=276250f0a36e00373166d91d539e5220d6f158c7;hp=d1d88d853d22e4dcd4f5a6203effffc76aed6e5e;hpb=b2ad0090c182c7f2a8cba1cced3987d408a4b159;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/redis.ts b/server/lib/redis.ts index d1d88d853..46617b07e 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts @@ -9,7 +9,8 @@ import { USER_PASSWORD_CREATE_LIFETIME, VIEW_LIFETIME, WEBSERVER, - TRACKER_RATE_LIMITS + TRACKER_RATE_LIMITS, + RESUMABLE_UPLOAD_SESSION_LIFETIME } from '../initializers/constants' import { CONFIG } from '../initializers/config' @@ -202,6 +203,30 @@ class Redis { ]) } + /* ************ Resumable uploads final responses ************ */ + + setUploadSession (uploadId: string, response?: { video: { id: number, shortUUID: string, uuid: string } }) { + return this.setValue( + 'resumable-upload-' + uploadId, + response + ? JSON.stringify(response) + : '', + RESUMABLE_UPLOAD_SESSION_LIFETIME + ) + } + + doesUploadSessionExist (uploadId: string) { + return this.exists('resumable-upload-' + uploadId) + } + + async getUploadSession (uploadId: string) { + const value = await this.getValue('resumable-upload-' + uploadId) + + return value + ? JSON.parse(value) + : '' + } + /* ************ Keys generation ************ */ generateCachedRouteKey (req: express.Request) {