mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-18 00:22:15 +02:00
fix: expire conference repositories before completing expiration
This commit is contained in:
@@ -33,10 +33,10 @@ export default class Conference {
|
|||||||
* Expire the conference
|
* Expire the conference
|
||||||
*/
|
*/
|
||||||
async expire() {
|
async expire() {
|
||||||
await this.updateStatus("expired");
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
(await this.repositories()).map(async (conf) => await conf.expire())
|
(await this.repositories()).map(async (conf) => await conf.expire())
|
||||||
);
|
);
|
||||||
|
await this.updateStatus("expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ router.get("/", async (req: express.Request, res: express.Response) => {
|
|||||||
).map(async (data) => {
|
).map(async (data) => {
|
||||||
const conf = new Conference(data);
|
const conf = new Conference(data);
|
||||||
if (data.endDate < new Date() && data.status == "ready") {
|
if (data.endDate < new Date() && data.status == "ready") {
|
||||||
await conf.updateStatus("expired");
|
await conf.expire();
|
||||||
}
|
}
|
||||||
return conf;
|
return conf;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -232,6 +232,15 @@ describe("production regressions", function () {
|
|||||||
expect(res.headers["Content-Security-Policy"]).to.include("sandbox");
|
expect(res.headers["Content-Security-Policy"]).to.include("sandbox");
|
||||||
expect(res.headers["Content-Security-Policy"]).not.to.include("allow-same-origin");
|
expect(res.headers["Content-Security-Policy"]).not.to.include("allow-same-origin");
|
||||||
});
|
});
|
||||||
|
it("keeps a conference eligible for retry when repository expiration fails", async function () {
|
||||||
|
const Conference = require("../src/core/Conference").default;
|
||||||
|
const model = { status: "ready", save: async () => {} };
|
||||||
|
const conference = new Conference(model);
|
||||||
|
conference.repositories = async () => [{ expire: async () => { throw new Error("storage failed"); } }];
|
||||||
|
try { await conference.expire(); throw new Error("expected rejection"); }
|
||||||
|
catch (error) { expect(error.message).to.equal("storage failed"); }
|
||||||
|
expect(model.status).to.equal("ready");
|
||||||
|
});
|
||||||
it("omits an upstream length when later text is rewritten", async function () {
|
it("omits an upstream length when later text is rewritten", async function () {
|
||||||
const File = require("../src/core/AnonymizedFile").default;
|
const File = require("../src/core/AnonymizedFile").default;
|
||||||
stub(config, "STREAMER_ENTRYPOINT", "");
|
stub(config, "STREAMER_ENTRYPOINT", "");
|
||||||
|
|||||||
Reference in New Issue
Block a user