@queria-io/fdl-js 0.5.0 → 0.7.0
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/README.md +3 -3
- package/dist/maintain.d.ts +11 -7
- package/dist/maintain.js +102 -30
- package/dist/maintain.js.map +1 -1
- package/package.json +1 -1
- package/src/maintain.ts +115 -29
package/README.md
CHANGED
|
@@ -45,15 +45,15 @@ Each retries a failed request once. A store is three functions (`text`, `size`,
|
|
|
45
45
|
|
|
46
46
|
## Retention
|
|
47
47
|
|
|
48
|
-
For the host of a repository: `expire(store, { keep })` takes
|
|
48
|
+
For the host of a repository: `expire(store, { keep, graceMs })` takes versions out of retention as `fdl expire` does, keeping the newest `keep` on each branch, the versions refs point at, their merge bases with main, and those made within the grace period, and `collect(store, { graceMs })` deletes the data files no live version reaches once past the grace period, as `fdl gc` does. Both read `files.json` and never open a catalog. Assets are deleted only while no live version's rows hold assets.
|
|
49
49
|
|
|
50
50
|
```ts
|
|
51
51
|
const store = r2MaintainedStore(env.BUCKET, "towns/");
|
|
52
|
-
await expire(store, { keep: 7 });
|
|
52
|
+
await expire(store, { keep: 7, graceMs: 86_400_000 });
|
|
53
53
|
await collect(store, { graceMs: 86_400_000 });
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
`expire` and `collect` take `{ dryRun: true }` to list the versions or keys without changing anything. Any store with `list` (keys and when they were written), `put` and `delete` works. `expire` also takes `by` (a person, or a process such as a scheduled job), which it records in each `expired.json`.
|
|
56
|
+
`expire` and `collect` take `{ dryRun: true }` to list the versions or keys without changing anything. Any store with `list` (keys and when they were written), `put` and `delete` works. `expire` also takes `by` (a person, or a process such as a scheduled job) and `message` (why, in free text), which it records in each `expired.json`.
|
|
57
57
|
|
|
58
58
|
## What it follows
|
|
59
59
|
|
package/dist/maintain.d.ts
CHANGED
|
@@ -32,24 +32,28 @@ export type R2Writable = R2Like & {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const r2MaintainedStore: (bucket: R2Writable, prefix: string, reader?: Store) => MaintainedStore;
|
|
34
34
|
export type ExpireOptions = {
|
|
35
|
-
/** How many of the newest versions on
|
|
35
|
+
/** How many of the newest versions on each branch's first-parent line to keep (at least 1) */
|
|
36
36
|
keep: number;
|
|
37
|
-
ref?: string;
|
|
38
37
|
/** Also keep the versions created at or after this time */
|
|
39
38
|
since?: Date;
|
|
39
|
+
/** Also keep the versions created less than this long ago: a writer puts a version before it moves a ref to it */
|
|
40
|
+
graceMs: number;
|
|
40
41
|
/** Who or what takes the versions out, recorded in `expired.json` */
|
|
41
42
|
by?: string;
|
|
43
|
+
/** Why, in free text for people, recorded in `expired.json` */
|
|
44
|
+
message?: string;
|
|
42
45
|
now?: Date;
|
|
43
46
|
/** List only. Default false */
|
|
44
47
|
dryRun?: boolean;
|
|
45
48
|
};
|
|
46
49
|
/**
|
|
47
|
-
* Takes
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* Takes versions out of retention, as `fdl expire` does, choosing them as the spec does
|
|
51
|
+
* (https://fdl.queria.io/spec/data-files#choosing-the-versions-to-take-out). Kept are the
|
|
52
|
+
* versions a ref points at, their merge bases with main, the newest `keep` on each branch's
|
|
53
|
+
* first-parent line, and those created at or after `since` or within the grace period. Nothing
|
|
54
|
+
* is taken out before main has a version. Returns the IDs taken out, newest first
|
|
51
55
|
*/
|
|
52
|
-
export declare const expire: (store: MaintainedStore, { keep,
|
|
56
|
+
export declare const expire: (store: MaintainedStore, { keep, since, graceMs, by, message, now, dryRun }: ExpireOptions) => Promise<string[]>;
|
|
53
57
|
export type CollectOptions = {
|
|
54
58
|
/** Objects written more recently than this are kept */
|
|
55
59
|
graceMs: number;
|
package/dist/maintain.js
CHANGED
|
@@ -42,17 +42,71 @@ const record = async (store, id) => {
|
|
|
42
42
|
};
|
|
43
43
|
const isExpired = async (store, id) => (await store.text(`versions/${id}/expired.json`)) !== null;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* read is not, since a version a ref points at must not be taken out
|
|
45
|
+
* Every ref that holds a version, with the version. A ref that does not hold a version ID is
|
|
46
|
+
* skipped; a failed read is not, since a version a ref points at must not be taken out
|
|
47
47
|
*/
|
|
48
|
-
const
|
|
48
|
+
const refTargets = async (store) => {
|
|
49
49
|
const keys = (await store.list("refs/")).map((p) => p.key);
|
|
50
50
|
const targets = await Promise.all(keys.map((key) => resolve(store, key).catch((e) => {
|
|
51
51
|
if (e instanceof FdlError)
|
|
52
52
|
return null;
|
|
53
53
|
throw e;
|
|
54
54
|
})));
|
|
55
|
-
return new
|
|
55
|
+
return new Map(keys.flatMap((key, i) => {
|
|
56
|
+
const target = targets[i];
|
|
57
|
+
return typeof target === "string" ? [[key, target]] : [];
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
/** The versions some ref points at */
|
|
61
|
+
const held = async (store) => new Set((await refTargets(store)).values());
|
|
62
|
+
/** Reads each version's record once. A version without `version.json` cannot be accounted for */
|
|
63
|
+
const records = (store) => {
|
|
64
|
+
const read = new Map();
|
|
65
|
+
return (id) => {
|
|
66
|
+
const known = read.get(id);
|
|
67
|
+
if (known)
|
|
68
|
+
return known;
|
|
69
|
+
const reading = record(store, id).then((head) => {
|
|
70
|
+
if (head === null)
|
|
71
|
+
throw new FdlError(`version ${id} has no version.json`);
|
|
72
|
+
return head;
|
|
73
|
+
});
|
|
74
|
+
read.set(id, reading);
|
|
75
|
+
return reading;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/** The version IDs among a record's parents. A parent in any other form is not followed */
|
|
79
|
+
const parentsOf = (head) => head.parents.filter(isVersionId);
|
|
80
|
+
/** `id` and every version behind it, through every parent */
|
|
81
|
+
const ancestors = async (id, read) => {
|
|
82
|
+
const found = new Set();
|
|
83
|
+
const pending = [id];
|
|
84
|
+
for (let current = pending.pop(); current !== undefined; current = pending.pop()) {
|
|
85
|
+
if (found.has(current))
|
|
86
|
+
continue;
|
|
87
|
+
found.add(current);
|
|
88
|
+
pending.push(...parentsOf(await read(current)).filter((parent) => !found.has(parent)));
|
|
89
|
+
}
|
|
90
|
+
return found;
|
|
91
|
+
};
|
|
92
|
+
/** The merge bases of two versions, from everything behind each: the common ancestors no other common ancestor descends from */
|
|
93
|
+
const mergeBases = async (mine, other, read) => {
|
|
94
|
+
const common = [...mine].filter((id) => other.has(id));
|
|
95
|
+
const behind = new Set((await Promise.all(common.map(read))).flatMap(parentsOf));
|
|
96
|
+
return common.filter((id) => !behind.has(id));
|
|
97
|
+
};
|
|
98
|
+
/** `id` and the versions behind it by first parent, `count` in all at most */
|
|
99
|
+
const firstParents = async (id, count, read) => {
|
|
100
|
+
const found = [id];
|
|
101
|
+
let current = id;
|
|
102
|
+
while (found.length < count) {
|
|
103
|
+
const parent = parentsOf(await read(current))[0];
|
|
104
|
+
if (parent === undefined)
|
|
105
|
+
break;
|
|
106
|
+
found.push(parent);
|
|
107
|
+
current = parent;
|
|
108
|
+
}
|
|
109
|
+
return found;
|
|
56
110
|
};
|
|
57
111
|
/**
|
|
58
112
|
* The metadata files to delete: the one the record names (`metadata`, or `catalog` in records
|
|
@@ -63,11 +117,11 @@ const metadataPaths = (head) => {
|
|
|
63
117
|
return isFileName(path) ? [path] : ["metadata.db", "ducklake.duckdb"];
|
|
64
118
|
};
|
|
65
119
|
/** Takes one version out of retention: the mark first, then its metadata and indexes */
|
|
66
|
-
const expireOne = async (store, id, head, now, by) => {
|
|
120
|
+
const expireOne = async (store, id, head, now, { by, message }) => {
|
|
67
121
|
const dir = `versions/${id}/`;
|
|
68
122
|
const metadata = new Set(metadataPaths(head).map((path) => dir + path));
|
|
69
123
|
if (!(await isExpired(store, id)))
|
|
70
|
-
await store.put(`${dir}expired.json`, `${JSON.stringify({ expired_at: now.toISOString(), reason: "retention", ...(by ? { by } : {}) })}\n`);
|
|
124
|
+
await store.put(`${dir}expired.json`, `${JSON.stringify({ expired_at: now.toISOString(), reason: "retention", ...(by ? { by } : {}), ...(message ? { message } : {}) })}\n`);
|
|
71
125
|
const indexed = (await store.list(dir))
|
|
72
126
|
.map((p) => p.key)
|
|
73
127
|
.filter((key) => metadata.has(key) ||
|
|
@@ -79,35 +133,53 @@ const expireOne = async (store, id, head, now, by) => {
|
|
|
79
133
|
key.startsWith(`${dir}profiles/`));
|
|
80
134
|
await store.delete(indexed);
|
|
81
135
|
};
|
|
136
|
+
const MAIN = "refs/heads/main";
|
|
82
137
|
/**
|
|
83
|
-
* Takes
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
138
|
+
* Takes versions out of retention, as `fdl expire` does, choosing them as the spec does
|
|
139
|
+
* (https://fdl.queria.io/spec/data-files#choosing-the-versions-to-take-out). Kept are the
|
|
140
|
+
* versions a ref points at, their merge bases with main, the newest `keep` on each branch's
|
|
141
|
+
* first-parent line, and those created at or after `since` or within the grace period. Nothing
|
|
142
|
+
* is taken out before main has a version. Returns the IDs taken out, newest first
|
|
87
143
|
*/
|
|
88
|
-
export const expire = async (store, { keep,
|
|
144
|
+
export const expire = async (store, { keep, since, graceMs, by, message, now = new Date(), dryRun = false }) => {
|
|
89
145
|
if (keep < 1)
|
|
90
146
|
throw new RangeError(`keep must be at least 1, got ${keep}`);
|
|
91
|
-
const
|
|
92
|
-
|
|
147
|
+
const targets = await refTargets(store);
|
|
148
|
+
const main = targets.get(MAIN);
|
|
149
|
+
if (main === undefined)
|
|
93
150
|
return [];
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
151
|
+
const read = records(store);
|
|
152
|
+
const kept = new Set(targets.values());
|
|
153
|
+
const behindMain = await ancestors(main, read);
|
|
154
|
+
for (const [name, target] of targets) {
|
|
155
|
+
if (target !== main)
|
|
156
|
+
for (const id of await mergeBases(behindMain, await ancestors(target, read), read))
|
|
157
|
+
kept.add(id);
|
|
158
|
+
if (name.startsWith("refs/heads/"))
|
|
159
|
+
for (const id of await firstParents(target, keep, read))
|
|
160
|
+
kept.add(id);
|
|
161
|
+
}
|
|
162
|
+
const cutoff = now.getTime() - graceMs;
|
|
163
|
+
const taken = [];
|
|
164
|
+
for (const id of await liveVersions(store)) {
|
|
165
|
+
if (kept.has(id))
|
|
166
|
+
continue;
|
|
167
|
+
const made = new Date((await read(id)).created_at).getTime();
|
|
168
|
+
if (Number.isNaN(made))
|
|
169
|
+
throw new FdlError(`version ${id} has no valid created_at`);
|
|
170
|
+
if (made >= cutoff || (since !== undefined && made >= since.getTime()))
|
|
171
|
+
continue;
|
|
172
|
+
taken.push(id);
|
|
173
|
+
}
|
|
174
|
+
taken.sort().reverse();
|
|
175
|
+
if (dryRun)
|
|
176
|
+
return taken;
|
|
177
|
+
// A ref may have come to point at one of them meanwhile
|
|
178
|
+
const stillHeld = await held(store);
|
|
179
|
+
const expired = taken.filter((id) => !stillHeld.has(id));
|
|
180
|
+
for (const id of expired)
|
|
181
|
+
await expireOne(store, id, await read(id), now, { by, message });
|
|
182
|
+
return expired;
|
|
111
183
|
};
|
|
112
184
|
const SHA256 = /^assets\/[0-9a-f]{64}$/;
|
|
113
185
|
/** A data or delete file as DuckLake names it, under data_dir */
|
package/dist/maintain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintain.js","sourceRoot":"","sources":["../src/maintain.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,2FAA2F;AAC3F,+FAA+F;AAC/F,sEAAsE;AACtE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAA2B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAuBzE,+CAA+C;AAC/C,MAAM,YAAY,GAAG,IA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AM,OAAO,GAAG,GAAG,EAAE,CACnB;QACE,yFAAyF;QACzF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACxF,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;KACpE,CAAC,IAAI,EAAE,CAAC;IACX,IAAI,MAAM;QAAE,OAAO,OAAO,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,OAAO,EAAE,CAAC;IAC1B,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/maintain.ts
CHANGED
|
@@ -88,10 +88,10 @@ const isExpired = async (store: Store, id: string) =>
|
|
|
88
88
|
(await store.text(`versions/${id}/expired.json`)) !== null;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
* read is not, since a version a ref points at must not be taken out
|
|
91
|
+
* Every ref that holds a version, with the version. A ref that does not hold a version ID is
|
|
92
|
+
* skipped; a failed read is not, since a version a ref points at must not be taken out
|
|
93
93
|
*/
|
|
94
|
-
const
|
|
94
|
+
const refTargets = async (store: MaintainedStore): Promise<Map<string, string>> => {
|
|
95
95
|
const keys = (await store.list("refs/")).map((p) => p.key);
|
|
96
96
|
const targets = await Promise.all(
|
|
97
97
|
keys.map((key) =>
|
|
@@ -101,7 +101,74 @@ const held = async (store: MaintainedStore): Promise<Set<string>> => {
|
|
|
101
101
|
}),
|
|
102
102
|
),
|
|
103
103
|
);
|
|
104
|
-
return new
|
|
104
|
+
return new Map(
|
|
105
|
+
keys.flatMap((key, i) => {
|
|
106
|
+
const target = targets[i];
|
|
107
|
+
return typeof target === "string" ? [[key, target] as const] : [];
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** The versions some ref points at */
|
|
113
|
+
const held = async (store: MaintainedStore): Promise<Set<string>> =>
|
|
114
|
+
new Set((await refTargets(store)).values());
|
|
115
|
+
|
|
116
|
+
/** Reads each version's record once. A version without `version.json` cannot be accounted for */
|
|
117
|
+
const records = (store: Store) => {
|
|
118
|
+
const read = new Map<string, Promise<Head>>();
|
|
119
|
+
return (id: string): Promise<Head> => {
|
|
120
|
+
const known = read.get(id);
|
|
121
|
+
if (known) return known;
|
|
122
|
+
const reading = record(store, id).then((head) => {
|
|
123
|
+
if (head === null) throw new FdlError(`version ${id} has no version.json`);
|
|
124
|
+
return head;
|
|
125
|
+
});
|
|
126
|
+
read.set(id, reading);
|
|
127
|
+
return reading;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** The version IDs among a record's parents. A parent in any other form is not followed */
|
|
132
|
+
const parentsOf = (head: Head): string[] => head.parents.filter(isVersionId);
|
|
133
|
+
|
|
134
|
+
/** `id` and every version behind it, through every parent */
|
|
135
|
+
const ancestors = async (id: string, read: (id: string) => Promise<Head>): Promise<Set<string>> => {
|
|
136
|
+
const found = new Set<string>();
|
|
137
|
+
const pending = [id];
|
|
138
|
+
for (let current = pending.pop(); current !== undefined; current = pending.pop()) {
|
|
139
|
+
if (found.has(current)) continue;
|
|
140
|
+
found.add(current);
|
|
141
|
+
pending.push(...parentsOf(await read(current)).filter((parent) => !found.has(parent)));
|
|
142
|
+
}
|
|
143
|
+
return found;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** The merge bases of two versions, from everything behind each: the common ancestors no other common ancestor descends from */
|
|
147
|
+
const mergeBases = async (
|
|
148
|
+
mine: Set<string>,
|
|
149
|
+
other: Set<string>,
|
|
150
|
+
read: (id: string) => Promise<Head>,
|
|
151
|
+
): Promise<string[]> => {
|
|
152
|
+
const common = [...mine].filter((id) => other.has(id));
|
|
153
|
+
const behind = new Set((await Promise.all(common.map(read))).flatMap(parentsOf));
|
|
154
|
+
return common.filter((id) => !behind.has(id));
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/** `id` and the versions behind it by first parent, `count` in all at most */
|
|
158
|
+
const firstParents = async (
|
|
159
|
+
id: string,
|
|
160
|
+
count: number,
|
|
161
|
+
read: (id: string) => Promise<Head>,
|
|
162
|
+
): Promise<string[]> => {
|
|
163
|
+
const found = [id];
|
|
164
|
+
let current = id;
|
|
165
|
+
while (found.length < count) {
|
|
166
|
+
const parent = parentsOf(await read(current))[0];
|
|
167
|
+
if (parent === undefined) break;
|
|
168
|
+
found.push(parent);
|
|
169
|
+
current = parent;
|
|
170
|
+
}
|
|
171
|
+
return found;
|
|
105
172
|
};
|
|
106
173
|
|
|
107
174
|
/**
|
|
@@ -119,14 +186,14 @@ const expireOne = async (
|
|
|
119
186
|
id: string,
|
|
120
187
|
head: Head,
|
|
121
188
|
now: Date,
|
|
122
|
-
by:
|
|
189
|
+
{ by, message }: Pick<ExpireOptions, "by" | "message">,
|
|
123
190
|
) => {
|
|
124
191
|
const dir = `versions/${id}/`;
|
|
125
192
|
const metadata = new Set(metadataPaths(head).map((path) => dir + path));
|
|
126
193
|
if (!(await isExpired(store, id)))
|
|
127
194
|
await store.put(
|
|
128
195
|
`${dir}expired.json`,
|
|
129
|
-
`${JSON.stringify({ expired_at: now.toISOString(), reason: "retention", ...(by ? { by } : {}) })}\n`,
|
|
196
|
+
`${JSON.stringify({ expired_at: now.toISOString(), reason: "retention", ...(by ? { by } : {}), ...(message ? { message } : {}) })}\n`,
|
|
130
197
|
);
|
|
131
198
|
const indexed = (await store.list(dir))
|
|
132
199
|
.map((p) => p.key)
|
|
@@ -144,45 +211,64 @@ const expireOne = async (
|
|
|
144
211
|
};
|
|
145
212
|
|
|
146
213
|
export type ExpireOptions = {
|
|
147
|
-
/** How many of the newest versions on
|
|
214
|
+
/** How many of the newest versions on each branch's first-parent line to keep (at least 1) */
|
|
148
215
|
keep: number;
|
|
149
|
-
ref?: string;
|
|
150
216
|
/** Also keep the versions created at or after this time */
|
|
151
217
|
since?: Date;
|
|
218
|
+
/** Also keep the versions created less than this long ago: a writer puts a version before it moves a ref to it */
|
|
219
|
+
graceMs: number;
|
|
152
220
|
/** Who or what takes the versions out, recorded in `expired.json` */
|
|
153
221
|
by?: string;
|
|
222
|
+
/** Why, in free text for people, recorded in `expired.json` */
|
|
223
|
+
message?: string;
|
|
154
224
|
now?: Date;
|
|
155
225
|
/** List only. Default false */
|
|
156
226
|
dryRun?: boolean;
|
|
157
227
|
};
|
|
158
228
|
|
|
229
|
+
const MAIN = "refs/heads/main";
|
|
230
|
+
|
|
159
231
|
/**
|
|
160
|
-
* Takes
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
232
|
+
* Takes versions out of retention, as `fdl expire` does, choosing them as the spec does
|
|
233
|
+
* (https://fdl.queria.io/spec/data-files#choosing-the-versions-to-take-out). Kept are the
|
|
234
|
+
* versions a ref points at, their merge bases with main, the newest `keep` on each branch's
|
|
235
|
+
* first-parent line, and those created at or after `since` or within the grace period. Nothing
|
|
236
|
+
* is taken out before main has a version. Returns the IDs taken out, newest first
|
|
164
237
|
*/
|
|
165
238
|
export const expire = async (
|
|
166
239
|
store: MaintainedStore,
|
|
167
|
-
{ keep,
|
|
240
|
+
{ keep, since, graceMs, by, message, now = new Date(), dryRun = false }: ExpireOptions,
|
|
168
241
|
): Promise<string[]> => {
|
|
169
242
|
if (keep < 1) throw new RangeError(`keep must be at least 1, got ${keep}`);
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
243
|
+
const targets = await refTargets(store);
|
|
244
|
+
const main = targets.get(MAIN);
|
|
245
|
+
if (main === undefined) return [];
|
|
246
|
+
const read = records(store);
|
|
247
|
+
const kept = new Set(targets.values());
|
|
248
|
+
const behindMain = await ancestors(main, read);
|
|
249
|
+
for (const [name, target] of targets) {
|
|
250
|
+
if (target !== main)
|
|
251
|
+
for (const id of await mergeBases(behindMain, await ancestors(target, read), read))
|
|
252
|
+
kept.add(id);
|
|
253
|
+
if (name.startsWith("refs/heads/"))
|
|
254
|
+
for (const id of await firstParents(target, keep, read)) kept.add(id);
|
|
255
|
+
}
|
|
256
|
+
const cutoff = now.getTime() - graceMs;
|
|
257
|
+
const taken: string[] = [];
|
|
258
|
+
for (const id of await liveVersions(store)) {
|
|
259
|
+
if (kept.has(id)) continue;
|
|
260
|
+
const made = new Date((await read(id)).created_at).getTime();
|
|
261
|
+
if (Number.isNaN(made)) throw new FdlError(`version ${id} has no valid created_at`);
|
|
262
|
+
if (made >= cutoff || (since !== undefined && made >= since.getTime())) continue;
|
|
263
|
+
taken.push(id);
|
|
264
|
+
}
|
|
265
|
+
taken.sort().reverse();
|
|
266
|
+
if (dryRun) return taken;
|
|
267
|
+
// A ref may have come to point at one of them meanwhile
|
|
268
|
+
const stillHeld = await held(store);
|
|
269
|
+
const expired = taken.filter((id) => !stillHeld.has(id));
|
|
270
|
+
for (const id of expired) await expireOne(store, id, await read(id), now, { by, message });
|
|
271
|
+
return expired;
|
|
186
272
|
};
|
|
187
273
|
|
|
188
274
|
type FileList = {
|