mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-01 14:19:34 +02:00
fix: address streamer review edge cases
This commit is contained in:
1 parent
c9c729c2c5
commit
2e6b79b30d
5 files changed
+55
-21
No files matched your search
@@ -508,7 +508,7 @@ export default class AnonymizedFile {
|
||||
resolve();
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error, res);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ export default class GitHubStream extends GitHubBase {
|
||||
const url = githubRawFileUrl(
|
||||
this.data.organization,
|
||||
this.data.repoName,
|
||||
this.data.commit,
|
||||
this.data.commit || "HEAD",
|
||||
filePath
|
||||
);
|
||||
logger.debug("downloading via raw URL (LFS)", { url });
|
||||
|
||||
+15
-9
@@ -75,17 +75,23 @@ export async function streamAnonymizedZip(
|
||||
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
||||
}
|
||||
): Promise<void> {
|
||||
const source = new GitHubDownload({
|
||||
repoId: opt.repoId,
|
||||
organization: opt.organization,
|
||||
repoName: opt.repoName,
|
||||
commit: opt.commit,
|
||||
getToken: opt.getToken,
|
||||
});
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await source.getZipUrl();
|
||||
const token = await opt.getToken();
|
||||
if (!token) {
|
||||
// The API already checked public access. Codeload serves public archives
|
||||
// directly, avoiding the streamer's shared unauthenticated REST quota.
|
||||
response = { url: `https://codeload.github.com/${encodeURIComponent(opt.organization)}/${encodeURIComponent(opt.repoName)}/zip/${encodeURIComponent(opt.commit || "HEAD")}` };
|
||||
} else {
|
||||
const source = new GitHubDownload({
|
||||
repoId: opt.repoId,
|
||||
organization: opt.organization,
|
||||
repoName: opt.repoName,
|
||||
commit: opt.commit,
|
||||
getToken: () => token,
|
||||
});
|
||||
response = await source.getZipUrl();
|
||||
}
|
||||
} catch (error) {
|
||||
const code = await classifyGitHubMissError(error, {
|
||||
organization: opt.organization,
|
||||
|
||||
Reference in new issue
Block a user