mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-14 00:07:00 +01:00
fix: preserve cache fallback and stream failures during access checks
This commit is contained in:
1 parent
4fc3c2e042
commit
07458f536a
3 files changed
+41
-2
No files matched your search
@@ -19,6 +19,9 @@ export function streamResponse(source: Readable, response: Writable,
|
||||
response.once("finish", done);
|
||||
response.once("error", failed);
|
||||
source.once("error", upstreamFailed);
|
||||
if (response.destroyed || response.writableEnded) done(); else source.pipe(response);
|
||||
if (response.destroyed || response.writableEnded) done();
|
||||
else if (source.errored) upstreamFailed(source.errored);
|
||||
else if (source.destroyed || source.readableEnded) upstreamFailed(new Error("upstream_stream_closed"));
|
||||
else source.pipe(response);
|
||||
});
|
||||
}
|
||||
@@ -402,7 +402,12 @@ export default class GitHubStream extends GitHubBase {
|
||||
if (cacheOnly) {
|
||||
await assertActive();
|
||||
if (expected.size != null && expected.size > config.MAX_FILE_SIZE) throw new AnonymousError("file_too_big", { httpStatus: 413 });
|
||||
const hit = /^[a-f0-9]{40}$/.test(expected.sha) ? await shared?.lookup(`git-${expected.sha}`) : undefined;
|
||||
let hit;
|
||||
try { hit = /^[a-f0-9]{40}$/.test(expected.sha) ? await shared?.lookup(`git-${expected.sha}`) : undefined; }
|
||||
catch (error) {
|
||||
if (!(error instanceof CacheAdmissionError)) throw error;
|
||||
throw new AnonymousError("cache_miss", { httpStatus: 409 });
|
||||
}
|
||||
if (!hit) throw new AnonymousError("cache_miss", { httpStatus: 409 });
|
||||
// Resolved LFS payloads may need additional billing admission. Let the
|
||||
// normal path reserve that expansion before serving it.
|
||||
|
||||
Reference in new issue
Block a user