From d1a1b7dc947063aef5f8375a6a1e03246b272c84 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 18 Aug 2021 17:29:55 +0200 Subject: Implemented caching for certain API endpoints, Added documentation & made backend-fixes --- packages/server/src/git/diff.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'packages/server/src/git/diff.ts') diff --git a/packages/server/src/git/diff.ts b/packages/server/src/git/diff.ts index d084e5d..a2c8829 100644 --- a/packages/server/src/git/diff.ts +++ b/packages/server/src/git/diff.ts @@ -1,5 +1,5 @@ import { Diff as NodeGitDiff } from "nodegit"; -import { createError, ErrorWhere, NotFoundError } from "./error"; +import { createError, DiffTooLargeError, ErrorWhere, NotFoundError } from "./error"; import { Patch } from "./patch"; type PatchHeaderData = { @@ -63,6 +63,10 @@ export class Diff { * @returns An array of patch instances */ public async patches(): Promise { + if((await this.rawPatches()).split("\n").length > 50000) { + throw(createError(ErrorWhere.Diff, DiffTooLargeError)); + } + return (await this.ng_diff.patches()).map((patch, index) => new Patch(this, patch, index)); } -- cgit v1.2.3-18-g5258