@mmon-co/ncept-local 0.3.8 → 0.3.9
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/directory.js +10 -4
- package/package.json +1 -1
package/dist/directory.js
CHANGED
|
@@ -120,14 +120,20 @@ async function locked(dir, operation) {
|
|
|
120
120
|
await release();
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
function installedPin(files, theories) {
|
|
124
|
+
const { theory, range } = parseManifest(files.get("profile.json")).theory;
|
|
125
|
+
const version = theories.find((candidate) => candidate.id === theory)?.version;
|
|
126
|
+
return version !== undefined && range === "~" + version.split(".").slice(0, 2).join(".");
|
|
127
|
+
}
|
|
123
128
|
export async function openProfile(dir, theories, options = {}) {
|
|
124
129
|
dir = resolve(dir);
|
|
125
130
|
const readOnlyFiles = options.readOnly ? await filesAt(dir) : undefined;
|
|
126
|
-
|
|
131
|
+
// A read-only open migrates like a writable one, but only takes the lock (and pays a second
|
|
132
|
+
// validation beyond read()'s) when the Lesson log or the stored Theory pin is behind.
|
|
133
|
+
if (!readOnlyFiles || migrateLessonLog(readOnlyFiles) !== readOnlyFiles || !installedPin(readOnlyFiles, theories))
|
|
127
134
|
await locked(dir, async () => {
|
|
128
135
|
const stored = await filesAt(dir);
|
|
129
|
-
const initial =
|
|
130
|
-
const profile = validate(initial, theories);
|
|
136
|
+
const initial = migrateProfileFiles(stored, theories);
|
|
131
137
|
// Immutable data first, then a single atomic live-head/log/pin switch. An interruption
|
|
132
138
|
// leaves either the old generation or the complete new one; retry never repeats a step.
|
|
133
139
|
for (const [path, bytes] of initial) {
|
|
@@ -140,7 +146,7 @@ export async function openProfile(dir, theories, options = {}) {
|
|
|
140
146
|
if (options.readOnly)
|
|
141
147
|
return;
|
|
142
148
|
// A copied or moved Profile must still appear in pi's cwd-filtered /resume list.
|
|
143
|
-
for (const filename of Object.values(
|
|
149
|
+
for (const filename of Object.values(parseManifest(manifest).sessions)) {
|
|
144
150
|
const path = "sessions/" + filename;
|
|
145
151
|
const bytes = initial.get(path);
|
|
146
152
|
if (bytes) {
|