fix: fix GitHubDownload

This commit is contained in:
tdurieux
2024-04-03 13:24:34 +01:00
parent fc469be61b
commit db67f53b2c
7 changed files with 112 additions and 57 deletions

View File

@@ -3,6 +3,8 @@ import GitHubStream from "../core/source/GitHubStream";
import { AnonymizeTransformer, isTextFile } from "../core/anonymize-utils";
import { handleError } from "../server/routes/route-utils";
import { contentType } from "mime-types";
import storage from "../core/storage";
import AnonymizedFile from "../core/AnonymizedFile";
export const router = express.Router();
@@ -25,7 +27,11 @@ router.post("/", async (req: express.Request, res: express.Response) => {
commit: commit,
getToken: () => token,
});
const content = source.downloadFile(token, fileSha);
const content = await source.getFileContentCache(
filePath,
repoId,
() => fileSha
);
try {
const mime = contentType(filePath);
if (mime && !filePath.endsWith(".ts")) {