pmtiles-swarm 0.5.2 → 0.5.3

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.5.3
11
+ ### 🐞 Bug fixes
12
+ - **A "high" priority hint asked for nothing at all.** libtorrent's scale runs 0 to 7 and **4 is
13
+ the default every piece already has** — and high was mapped to 4. So the JSON metadata, which
14
+ the source hints the moment it reads a header, was raised to precisely what the other eighteen
15
+ thousand pieces already had, and waited its turn: hours, on a 72 GiB archive. It is 6 now,
16
+ above the default and below critical, so it arrives soon without ever going ahead of a tile
17
+ somebody is waiting for. `normal` stays at 1, deliberately below the default, because that is
18
+ what the idle leaf hydration uses and it must yield to everything.
19
+
20
+ There is a test for the mapping itself, since a priority that is merely ordinary fails by
21
+ doing nothing, which no behavioural test would notice.
22
+ - **A partial head-read no longer reports itself as a complete one.** The header sits at byte
23
+ zero while the JSON metadata is wherever the writer put it — planetiler puts it after every
24
+ tile, so at the far end of the file — and `summarize` treats the second as decoration, so a
25
+ pass that got only the header still returned a summary and logged "read the head". It then
26
+ came back two minutes later, having genuinely succeeded and genuinely not finished, with
27
+ nothing in the log to explain the repetition. The two are now reported separately.
28
+
10
29
  ## 0.5.2
11
30
  ### 🐞 Bug fixes
12
31
  - **Asks for the `pmtiles-torrent` that 0.5.1 actually needs.** It shipped declaring `^0.3.2`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmtiles-swarm",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
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",
package/src/prewarm.js CHANGED
@@ -128,12 +128,25 @@ export class HeadWarmer {
128
128
  infoHash: entry.infoHash,
129
129
  pmtiles: { ...entry.pmtiles, ...summary },
130
130
  });
131
- console.log(
132
- `[warm] read the head of ${entry.name}` +
133
- (summary.vectorLayers
134
- ? ` (${summary.vectorLayers.length} vector layers)`
135
- : ''),
136
- );
131
+ // Said accurately, because the two halves arrive separately and the
132
+ // difference matters: the header is at byte zero, while the JSON
133
+ // metadata is wherever the writer put it — planetiler puts it after every
134
+ // tile, so on a 72 GiB archive it is the very end of the file. Reporting
135
+ // both as "read the head" made a pass that got half of it look complete,
136
+ // and left the repeat every couple of minutes unexplained.
137
+ if (summary.vectorLayers) {
138
+ console.log(
139
+ `[warm] ${entry.name}: header and metadata read ` +
140
+ `(${summary.vectorLayers.length} vector layers)`,
141
+ );
142
+ } else if (summary.format === 'pbf') {
143
+ console.log(
144
+ `[warm] ${entry.name}: header read; its metadata is at the far end ` +
145
+ 'of the archive and has not arrived yet',
146
+ );
147
+ } else {
148
+ console.log(`[warm] ${entry.name}: header read`);
149
+ }
137
150
  return stored;
138
151
  } catch (error) {
139
152
  if (tooEarly(error)) {
@@ -9,7 +9,21 @@
9
9
  */
10
10
 
11
11
  /** libtorrent piece priorities. 0 means "do not fetch". */
12
- const LT_PRIORITY = { critical: 7, high: 4, normal: 1 };
12
+ /**
13
+ * What a hint's priority means to libtorrent.
14
+ *
15
+ * libtorrent's scale runs 0 (do not download) to 7 (highest), and **4 is the
16
+ * default every piece already has**. So "high" was mapped to the default: the
17
+ * JSON metadata, which the source hints as high the moment it reads the header,
18
+ * was never prioritised at all — it waited its turn like the other eighteen
19
+ * thousand pieces, which on a 72 GiB archive is hours.
20
+ *
21
+ * 6 is above the default and below critical, which is what "fetch this sooner
22
+ * than the rest, but not ahead of a tile somebody is waiting for" should mean.
23
+ * `normal` stays at 1, deliberately *below* the default: it is what the idle
24
+ * leaf hydration uses, and that must yield to everything.
25
+ */
26
+ const LT_PRIORITY = { critical: 7, high: 6, normal: 1 };
13
27
 
14
28
  /**
15
29
  * A TorrentEngine over the libtorrent sidecar the seed engine already runs.