diff options
author | HampusM <hampus@hampusmat.com> | 2021-08-18 17:29:55 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-08-18 17:29:55 +0200 |
commit | d1a1b7dc947063aef5f8375a6a1e03246b272c84 (patch) | |
tree | f5cb9bd6d4b5463d9d022026ac6fea87cb6ebe02 /packages/server/src/git/diff.ts | |
parent | 6ed078de30a7bf35deace728857d1d293d59eb15 (diff) |
Implemented caching for certain API endpoints, Added documentation & made backend-fixes
Diffstat (limited to 'packages/server/src/git/diff.ts')
-rw-r--r-- | packages/server/src/git/diff.ts | 6 |
1 files changed, 5 insertions, 1 deletions
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<Patch[]> { + 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)); } |