mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 21:57:57 +02:00
fix: fix error message when file is not found
This commit is contained in:
@@ -167,9 +167,8 @@ export default class AnonymizedFile {
|
|||||||
}
|
}
|
||||||
if (await storage.exists(this.originalCachePath)) {
|
if (await storage.exists(this.originalCachePath)) {
|
||||||
return storage.read(this.originalCachePath);
|
return storage.read(this.originalCachePath);
|
||||||
} else {
|
|
||||||
return await this.repository.source?.getFileContent(this);
|
|
||||||
}
|
}
|
||||||
|
return await this.repository.source?.getFileContent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
async anonymizedContent() {
|
async anonymizedContent() {
|
||||||
@@ -192,8 +191,7 @@ export default class AnonymizedFile {
|
|||||||
try {
|
try {
|
||||||
await pipe(await this.anonymizedContent(), res);
|
await pipe(await this.anonymizedContent(), res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error);
|
handleError(error, res);
|
||||||
res.end();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export function handleError(
|
|||||||
} else if (message && message.indexOf("not_connected") > -1) {
|
} else if (message && message.indexOf("not_connected") > -1) {
|
||||||
status = 401;
|
status = 401;
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res && !res.headersSent) {
|
||||||
res.status(status).send({ error: message });
|
res.status(status).send({ error: message });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ export default async function start() {
|
|||||||
app.set("trust proxy", config.TRUST_PROXY);
|
app.set("trust proxy", config.TRUST_PROXY);
|
||||||
app.set("etag", "strong");
|
app.set("etag", "strong");
|
||||||
|
|
||||||
|
app.get('/ip', (request, response) => response.send(request.ip))
|
||||||
|
|
||||||
// handle session and connection
|
// handle session and connection
|
||||||
app.use(connection.appSession);
|
app.use(connection.appSession);
|
||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
|
|||||||
@@ -61,6 +61,13 @@ export default class GitHubStream extends GitHubBase implements SourceBase {
|
|||||||
await storage.write(file.originalCachePath, content, file, this);
|
await storage.write(file.originalCachePath, content, file, this);
|
||||||
return stream.Readable.from(content);
|
return stream.Readable.from(content);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.status == 404) {
|
||||||
|
throw new AnonymousError("file_not_found", {
|
||||||
|
httpStatus: error.status,
|
||||||
|
cause: error,
|
||||||
|
object: file,
|
||||||
|
});
|
||||||
|
}
|
||||||
throw new AnonymousError("file_too_big", {
|
throw new AnonymousError("file_too_big", {
|
||||||
httpStatus: error.status,
|
httpStatus: error.status,
|
||||||
cause: error,
|
cause: error,
|
||||||
|
|||||||
Reference in New Issue
Block a user