pmtiles-swarm 0.4.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@
7
7
  ### 🐞 Bug fixes
8
8
  - _...Add new stuff here..._
9
9
 
10
+ ## 0.4.1
11
+ ### 🐞 Bug fixes
12
+ - **A feed no longer walks backwards through its own history.** An item already taken was
13
+ skipped and the loop carried on to the older one below it, and the cap counts what was
14
+ *added* — so every poll took exactly one archive and every poll took a different one, until
15
+ the whole backlog was on disk. Against planet.openstreetmap.org that is five 88 GiB dumps
16
+ arriving a quarter of an hour apart from a subscription asking for one. Items run newest
17
+ first, so reaching one already held now stops the pass: everything after it is older than
18
+ something already on disk. A build that could not be fetched stops it too — one bad fetch is
19
+ a reason to retry shortly, not to take last week's instead.
20
+ - **A subscription's `mode` had no effect.** It reached the add as `paused`, which nothing
21
+ reads — not the library and not the engine — so every item a feed brought in arrived as a
22
+ cache whatever the subscription said, and a `"mode": "mirror"` feed quietly fetched nothing.
23
+ A cache subscription only looked correct because cache is the default. It is now passed as
24
+ `mode`, the name the library actually reads.
25
+ - **The console says what an empty availability bar means.** It counts connected peers and not
26
+ this node, so an archive only this node holds shows nothing — the truth about the swarm rather
27
+ than about the file, but worth saying beside a Downloaded bar that is full.
28
+
10
29
  ## 0.4.0
11
30
  ### ✨ Features and improvements
12
31
  - **A watched folder can set the torrent comment**, which is where attribution and licence belong —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmtiles-swarm",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "BitTorrent distribution for PMTiles map archives: create torrents, watch folders, publish and subscribe to RSS feeds, and seed through qBittorrent or an embedded client",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -141,12 +141,26 @@ export class SubscriptionManager {
141
141
  continue;
142
142
  }
143
143
  const marker = item.infoHash ?? item.magnet ?? item.torrentUrl;
144
- if (this.#seen.has(marker)) continue;
145
- this.#seen.add(marker);
144
+
145
+ // Stop, rather than skip past it to the next one.
146
+ //
147
+ // Items run newest first, so reaching one already taken means
148
+ // everything after it is older than something on disk. Skipping to the
149
+ // next instead takes one more archive every poll and walks backwards
150
+ // through the feed until the whole backlog is held — which for the
151
+ // planet feed is five 88 GiB dumps nobody asked for, arriving one a
152
+ // quarter of an hour apart. The cap counts what was added, so it does
153
+ // not stop this: each poll adds exactly one, and each poll adds a
154
+ // different one.
155
+ if (this.#seen.has(marker)) break;
146
156
 
147
157
  try {
148
158
  const entry = await this.#add(item, subscription);
149
159
  if (entry) {
160
+ // Marked only once it worked. A .torrent that 404s for an hour
161
+ // should be retried on the next poll rather than passed over for
162
+ // good on the strength of one bad fetch.
163
+ this.#seen.add(marker);
150
164
  added.push(entry);
151
165
  console.log(
152
166
  `[feed] ${subscription.mode ?? 'cache'} ${entry.name} from ${subscription.url}`,
@@ -154,6 +168,10 @@ export class SubscriptionManager {
154
168
  }
155
169
  } catch (error) {
156
170
  console.error(`[feed] could not add "${item.title}": ${error.message}`);
171
+ // And stop here too. The newest build being briefly unreachable is a
172
+ // reason to try again shortly, not a reason to fetch last week's
173
+ // instead — which is the same backwards walk by another route.
174
+ break;
157
175
  }
158
176
  }
159
177
  return added;
@@ -340,8 +358,15 @@ export class SubscriptionManager {
340
358
  // from one built here or added by hand, and would happily delete both.
341
359
  subscriptionUrl: subscription.url,
342
360
  // Cache mode joins the swarm without pulling the whole archive; the
343
- // pieces it does hold are still served to other peers.
344
- paused: (subscription.mode ?? 'cache') === 'cache',
361
+ // pieces it does hold are still served to other peers. Mirror commits to
362
+ // a whole copy.
363
+ //
364
+ // Passed as `mode`, which is the name the library reads. It had been
365
+ // passed as `paused`, which nothing reads — so a feed's mode did not
366
+ // reach the add at all, and every item arrived as cache whatever the
367
+ // subscription said. Defaulted here as well as there, so the two cannot
368
+ // drift apart into disagreeing about what an unset mode means.
369
+ mode: subscription.mode ?? 'cache',
345
370
  };
346
371
 
347
372
  // The .torrent is preferred where there is one: it carries the trackers
@@ -1190,7 +1190,9 @@
1190
1190
  shown as held when <i>all</i> of them are. Availability is the
1191
1191
  <i>rarest</i> piece in each column: one piece nobody has is the
1192
1192
  answer to "can this still be completed", however well supplied
1193
- its neighbours are.
1193
+ its neighbours are. It counts <i>connected peers</i> and not
1194
+ this node, so an archive only this node holds shows an empty
1195
+ bar — which is the truth about the swarm, not about the file.
1194
1196
  </div>
1195
1197
  ${
1196
1198
  (info.peers ?? []).length > 0