Add flag to persist builds
Some checks failed
App Image CI / Build app image (push) Successful in -1m2s
NPM Audit Check / Check NPM audit (push) Failing after -2m7s
Docker Image CI / Build build images (arch) (push) Successful in 47s
Docker Image CI / Build build images (artix) (push) Successful in -27s

This commit is contained in:
2025-11-26 18:20:44 -05:00
parent 7bd8bf4d85
commit d803a58ab8
9 changed files with 104 additions and 61 deletions

View File

@@ -30,6 +30,7 @@ interface Build {
pid?: number;
sqid?: string;
uuid: string;
persist: boolean;
}
interface User {
@@ -128,6 +129,10 @@ class DB extends Store {
uuid: {
type: DataTypes.STRING,
unique: true
},
persist: {
type: DataTypes.BOOLEAN,
defaultValue: false
}
});
@@ -262,6 +267,16 @@ class DB extends Store {
});
}
public async persist(id: number, persist: boolean = true): Promise<void> {
await this.build.update({
persist
}, {
where: {
id
}
});
}
public async appendLog(buildId: number, type: LogType, chunk: string): Promise<void> {
await this.logChunk.create({
buildId,
@@ -366,7 +381,8 @@ class DB extends Store {
public async cleanup(): Promise<void> {
await this.build.destroy({
where: {
startTime: { [Op.lt]: new Date(Date.now() - MONTH * 6) }
startTime: { [Op.lt]: new Date(Date.now() - MONTH * 6) },
persist: { [Op.eq]: false }
},
force: true
});

View File

@@ -297,6 +297,17 @@ class Web {
res.redirect(`/build/${req.params.id}/`);
});
app.post('/build/:id/persist', async (req, res) => {
const build = await this.db.getBuild(sqids.decode(req.params.id)?.[0]);
const persist = !! req?.body?.persist;
if (!build) {
res.sendStatus(404);
return;
}
await this.db.persist(build.id, persist);
res.sendStatus(200);
})
this._webserver = this.app.listen(this.port, () => console.log(`archery is running on port ${this.port}`));
}