From 0a10c326d9e56154686ec94bc53bbabe6cd54341 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 24 Jul 2021 23:40:18 +0200 Subject: Cleaned up & improved the git http backend --- packages/server/src/api/util.ts | 8 ++-- packages/server/src/git/http.ts | 84 +++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 54 deletions(-) (limited to 'packages/server/src') diff --git a/packages/server/src/api/util.ts b/packages/server/src/api/util.ts index e7e7657..0314db7 100644 --- a/packages/server/src/api/util.ts +++ b/packages/server/src/api/util.ts @@ -1,7 +1,5 @@ import { Commit } from "../git/commit"; import { Repository } from "../git/repository"; -import { RequestInfo } from "../git/http"; -import { readdir } from "fs"; type VerificationResultType = "SUCCESS" | "NOT_FOUND" | "INVALID" | "ACCESS_DENIED"; @@ -44,12 +42,12 @@ export async function verifySHA(repository: Repository, sha: string): Promise { - git_pack.stdin.write(data); - }); - request_body.on("end", () => { - git_pack.stdin.end(); + // Request error + req.raw.on("error", err => { + console.log(err); + git_service.stdin.end(); + reply.raw.end(); }); } - git_pack.on("error", err => console.log(err)); + // Spawn error + git_service.on("error", err => { + console.log(err); + reply.raw.end(); + }); - git_pack.stderr.on("data", (stderr: Buffer) => console.log(stderr.toString())); - git_pack.stdout.on("data", data => { - reply.raw.write(data); + // Git service error + git_service.stderr.on("data", (stderr: Buffer) => { + console.log(stderr.toString()); + reply.raw.end(); }); - git_pack.stdout.on("end", () => reply.raw.end()); + git_service.stdout.pipe(reply.raw); } \ No newline at end of file -- cgit v1.2.3-18-g5258