fedipod-bb 0.5.1 → 0.5.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/gateway.mjs +14 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fedipod-bb",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "FediPod-BB: a forum website whose record lives on a Solid pod.",
5
5
  "license": "MIT",
6
6
  "author": "Jeff Zucker",
package/src/gateway.mjs CHANGED
@@ -194,10 +194,14 @@ export async function keepOnce(ctx, handle, rec, { log = console.log, session =
194
194
  let asks = 0;
195
195
  try {
196
196
  forum = agentFor(ctx, f, { remote, podFetch, copies, log: say, mode: 'run' });
197
- if (!await forum.connect({ act: false })) return { skipped: 'no forum on the pod' };
198
- prepare?.(forum); // a test's origins, in place of the network
199
- if (!await forum.lease.acquire()) return { skipped: 'another host has the forum', retry: 'soon' };
197
+ // The lease before the connect: connecting writes a category's settings
198
+ // again where the forum's changed, and a copy takes a write only from
199
+ // the lease's holder.
200
+ const lease = forum.givenLease;
201
+ if (!await lease.acquire()) return { skipped: 'another host has the forum', retry: 'soon' };
200
202
  try {
203
+ if (!await forum.connect({ act: false })) return { skipped: 'no forum on the pod' };
204
+ prepare?.(forum); // a test's origins, in place of the network
201
205
  // A forum on a pod it has not published to — moved there, its rows
202
206
  // naming the new pod — is published there whole, and what that pod
203
207
  // lacks is read again from where its authors keep it. Recorded once
@@ -222,7 +226,7 @@ export async function keepOnce(ctx, handle, rec, { log = console.log, session =
222
226
  await Promise.allSettled(storesOf(forum).map((s) => s.flush()));
223
227
  asks = storesOf(forum).reduce((n, s) => n + s.read('modqueue.json', []).length, 0);
224
228
  before = new Map(storesOf(forum).map((s) => [s, s.getQueue?.() || []]));
225
- } finally { await forum.lease.release().catch(() => {}); }
229
+ } finally { await lease.release().catch(() => {}); }
226
230
  } finally { await unlock(); }
227
231
 
228
232
  // The carry, with the forum free.
@@ -278,15 +282,17 @@ export async function placeAtDoor(ctx, handle, rec, { name, raw, receipt = null,
278
282
  if (!unlock) return { ...out, why: 'the forum is busy' };
279
283
  try {
280
284
  const forum = agentFor(ctx, f, { remote, podFetch, copies, log: say, mode: 'door' });
281
- if (!await forum.connect({ act: false })) return { ...out, why: 'no forum on the pod' };
282
- prepare?.(forum); // a test's origins, in place of the network
283
- if (!await forum.lease.acquire()) return { ...out, why: 'another host has the forum' };
285
+ // The lease before the connect, as in the run.
286
+ const lease = forum.givenLease;
287
+ if (!await lease.acquire()) return { ...out, why: 'another host has the forum' };
284
288
  try {
289
+ if (!await forum.connect({ act: false })) return { ...out, why: 'no forum on the pod' };
290
+ prepare?.(forum); // a test's origins, in place of the network
285
291
  if (!await forum.placeOne(name, raw, receipt)) return { ...out, why: 'not done here; left for the run' };
286
292
  const item = f.home + 'ap/inbox/' + name;
287
293
  await podInbox.dropHandledItem(remote, item).catch(() => false);
288
294
  await podInbox.dropReceiptBeside(remote, item);
289
295
  return { ...out, placed: true };
290
- } finally { await forum.lease.release().catch(() => {}); }
296
+ } finally { await lease.release().catch(() => {}); }
291
297
  } finally { await unlock(); }
292
298
  }