mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Clear cache after purging segments
This commit is contained in:
parent
eaaf106d7c
commit
99d72b92e4
1 changed files with 10 additions and 1 deletions
|
@ -3,11 +3,13 @@ import { getHash } from "../utils/getHash";
|
|||
import { isUserVIP } from "../utils/isUserVIP";
|
||||
import { Request, Response } from "express";
|
||||
import { HashedUserID, UserID } from "../types/user.model";
|
||||
import { VideoID } from "../types/segments.model";
|
||||
import { Service, VideoID, VideoIDHash } from "../types/segments.model";
|
||||
import { db } from "../databases/databases";
|
||||
import { QueryCacher } from "../utils/queryCacher";
|
||||
|
||||
export async function postPurgeAllSegments(req: Request, res: Response): Promise<Response> {
|
||||
const userID = req.body.userID as UserID;
|
||||
const service = req.body.service as Service ?? Service.YouTube;
|
||||
const videoID = req.body.videoID as VideoID;
|
||||
|
||||
if (userID == undefined) {
|
||||
|
@ -28,6 +30,13 @@ export async function postPurgeAllSegments(req: Request, res: Response): Promise
|
|||
|
||||
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1 WHERE "videoID" = ?`, [videoID]);
|
||||
|
||||
const hashedVideoID: VideoIDHash = getHash(videoID, 1);
|
||||
QueryCacher.clearVideoCache({
|
||||
videoID,
|
||||
hashedVideoID,
|
||||
service
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
Logger.error(err as string);
|
||||
return res.sendStatus(500);
|
||||
|
|
Loading…
Reference in a new issue