@fungi.computer/oyster 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-builds.js +18 -6
- package/dist/embed-scripts.js +1 -1
- package/package.json +2 -2
package/dist/app-builds.js
CHANGED
|
@@ -249,14 +249,26 @@ export function createOysterAppBuilds(options) {
|
|
|
249
249
|
const logRef = (jobId) => parseArtifactRef(`artifact:build-log-${jobId}`);
|
|
250
250
|
const logCodec = Schema.fromJsonString(buildJobLogSchema);
|
|
251
251
|
// Job rows and statuses stay; only the older logs of one App are removed.
|
|
252
|
-
// The ranking is read from the job table each time
|
|
253
|
-
//
|
|
252
|
+
// The ranking is read from the job table each time and counts only jobs whose
|
|
253
|
+
// log is stored, so a refused, revoked or expired job takes no slot, and
|
|
254
|
+
// replays, retries and an owner restart can never delete a log inside the
|
|
255
|
+
// retained five.
|
|
254
256
|
const pruneLogs = async (appId) => {
|
|
255
|
-
const
|
|
256
|
-
.exec("SELECT job_id FROM oyster_build_jobs WHERE app_id=? ORDER BY issued_at DESC, rowid DESC
|
|
257
|
+
const jobs = owner.sql
|
|
258
|
+
.exec("SELECT job_id FROM oyster_build_jobs WHERE app_id=? ORDER BY issued_at DESC, rowid DESC", appId)
|
|
257
259
|
.toArray();
|
|
258
|
-
for
|
|
259
|
-
|
|
260
|
+
// Look for a stored log only until the fifth is found; every older job's
|
|
261
|
+
// log is deleted directly, since deleting a missing log is not an error.
|
|
262
|
+
let kept = 0;
|
|
263
|
+
for (const row of jobs) {
|
|
264
|
+
const ref = logRef(decodeJobId(row).job_id);
|
|
265
|
+
if (kept < retainedBuildLogs) {
|
|
266
|
+
if ((await options.artifacts.head(ref)) !== null)
|
|
267
|
+
kept += 1;
|
|
268
|
+
}
|
|
269
|
+
else
|
|
270
|
+
await options.artifacts.delete(ref);
|
|
271
|
+
}
|
|
260
272
|
};
|
|
261
273
|
const publisher = createTeamBuildPublisher({
|
|
262
274
|
teamId: options.tenantId,
|