pixivflow 3.4.1 → 3.4.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.
@@ -945,10 +945,19 @@ export interface StandaloneConfig {
945
945
  * classified. 'skip' (default) is safe mode: never ship an unclassifiable
946
946
  * cover, and log `coverType=unknown` so a future Pixiv format change is
947
947
  * visible instead of silently leaking designs again. 'keep' prefers
948
- * availability over certainty. A failed probe always keeps the cover.
948
+ * availability over certainty.
949
+ *
950
+ * `probeFailed` governs the separate case where the cover probe itself
951
+ * failed (network / auth / rate limit) and the bytes were never seen.
952
+ * 'skip' (default) is safe mode for the same reason: most novel covers ARE
953
+ * generated designs, so keeping an unseen cover re-ships what the 640x900
954
+ * classifier exists to suppress; the cost is one illustration when a real
955
+ * cover is transiently unreachable. 'keep' restores availability-first.
956
+ * Either way the `coverType=probe_failed` warning stays visible.
949
957
  */
950
958
  novelCover?: {
951
959
  unknown?: 'skip' | 'keep';
960
+ probeFailed?: 'skip' | 'keep';
952
961
  };
953
962
  };
954
963
  }
@@ -715,6 +715,11 @@ function validateConfig(config, location, databasePath) {
715
715
  config.download.novelCover.unknown !== 'keep') {
716
716
  errors.push(`download.novelCover.unknown: Must be "skip" or "keep" (got ${String(config.download.novelCover.unknown)})`);
717
717
  }
718
+ if (config.download.novelCover?.probeFailed !== undefined &&
719
+ config.download.novelCover.probeFailed !== 'skip' &&
720
+ config.download.novelCover.probeFailed !== 'keep') {
721
+ errors.push(`download.novelCover.probeFailed: Must be "skip" or "keep" (got ${String(config.download.novelCover.probeFailed)})`);
722
+ }
718
723
  }
719
724
  // The bounded candidate scan is what stops a page full of duplicates from
720
725
  // burning a whole scheduled slot, so a non-integer value is reported here.
@@ -15,14 +15,36 @@ export interface NovelCoverPolicy {
15
15
  * 'keep': prefer availability over certainty.
16
16
  */
17
17
  unknownCover: 'skip' | 'keep';
18
+ /**
19
+ * What to do when the cover probe itself failed (network / auth / rate
20
+ * limit), so the bytes were never fetched and no content type exists.
21
+ *
22
+ * 'skip' (default): safe mode — most novel covers ARE Pixiv's generated
23
+ * designs, so keeping an unseen probe failure re-ships exactly the covers
24
+ * the 640x900 classifier exists to suppress. The cost is one illustration
25
+ * when a real author cover happens to be transiently unreachable.
26
+ * 'keep': prefer availability over certainty — a failed probe never costs a
27
+ * cover, at the price of re-shipping generated designs whenever the CDN or
28
+ * the account is unreachable.
29
+ */
30
+ probeFailed: 'skip' | 'keep';
18
31
  }
19
- /** Production-safe default: an unclassifiable cover is never shipped. */
32
+ /**
33
+ * Production-safe default: an unclassifiable cover is never shipped, and a
34
+ * probe that never produced bytes is not treated as evidence that the cover is
35
+ * real content.
36
+ */
20
37
  export declare const DEFAULT_NOVEL_COVER_POLICY: NovelCoverPolicy;
21
38
  /**
22
39
  * Classify fetched cover bytes. Returns `unknown` when the image header cannot
23
40
  * be read (no decoder in this project, so only the header is inspected).
24
41
  */
25
42
  export declare function classifyNovelCover(cover: ArrayBuffer | Uint8Array | null | undefined): NovelCoverType;
26
- /** The delivery decision for one classified cover under a policy. */
27
- export declare function coverDeliveryDecision(policy: NovelCoverPolicy, type: NovelCoverType): 'deliver' | 'skip';
43
+ /**
44
+ * Everything `coverDeliveryDecision` can be asked about: the three results
45
+ * `classifyNovelCover` returns, plus the probe that never produced bytes.
46
+ */
47
+ export type NovelCoverOutcome = NovelCoverType | 'probe_failed';
48
+ /** The delivery decision for one cover outcome under a policy. */
49
+ export declare function coverDeliveryDecision(policy: NovelCoverPolicy, outcome: NovelCoverOutcome): 'deliver' | 'skip';
28
50
  //# sourceMappingURL=NovelCoverPolicy.d.ts.map
@@ -31,8 +31,15 @@ exports.coverDeliveryDecision = coverDeliveryDecision;
31
31
  * shipping generated covers again.
32
32
  *
33
33
  * A FAILED probe (network / auth / rate limit) is deliberately NOT `unknown`:
34
- * it is `probe_failed` and always keeps the cover, because a transient fetch
35
- * error must never cost a real one.
34
+ * it is `probe_failed` — the bytes were never seen, so no content type exists.
35
+ * It is a policy decision like `unknown` (`download.novelCover.probeFailed`),
36
+ * and the production-safe default is `skip`: the majority of novel covers ARE
37
+ * Pixiv's generated designs, so a probe failure that keeps the cover re-ships
38
+ * exactly the payloads the 640x900 classifier exists to suppress. `keep` stays
39
+ * available for an operator who prefers availability over certainty (a
40
+ * transient fetch error must never cost a real cover). Either way the loud
41
+ * `coverType=probe_failed` log line stays, so the decision is observable
42
+ * instead of silent.
36
43
  */
37
44
  const imageDimensions_1 = require("../../utils/imageDimensions");
38
45
  /**
@@ -43,8 +50,15 @@ const imageDimensions_1 = require("../../utils/imageDimensions");
43
50
  */
44
51
  exports.PIXIV_GENERATED_COVER_WIDTH = 640;
45
52
  exports.PIXIV_GENERATED_COVER_HEIGHT = 900;
46
- /** Production-safe default: an unclassifiable cover is never shipped. */
47
- exports.DEFAULT_NOVEL_COVER_POLICY = { unknownCover: 'skip' };
53
+ /**
54
+ * Production-safe default: an unclassifiable cover is never shipped, and a
55
+ * probe that never produced bytes is not treated as evidence that the cover is
56
+ * real content.
57
+ */
58
+ exports.DEFAULT_NOVEL_COVER_POLICY = {
59
+ unknownCover: 'skip',
60
+ probeFailed: 'skip',
61
+ };
48
62
  /**
49
63
  * Classify fetched cover bytes. Returns `unknown` when the image header cannot
50
64
  * be read (no decoder in this project, so only the header is inspected).
@@ -59,12 +73,14 @@ function classifyNovelCover(cover) {
59
73
  }
60
74
  return 'custom';
61
75
  }
62
- /** The delivery decision for one classified cover under a policy. */
63
- function coverDeliveryDecision(policy, type) {
64
- if (type === 'pixiv_generated')
76
+ /** The delivery decision for one cover outcome under a policy. */
77
+ function coverDeliveryDecision(policy, outcome) {
78
+ if (outcome === 'pixiv_generated')
65
79
  return 'skip';
66
- if (type === 'unknown')
80
+ if (outcome === 'unknown')
67
81
  return policy.unknownCover === 'keep' ? 'deliver' : 'skip';
82
+ if (outcome === 'probe_failed')
83
+ return policy.probeFailed === 'keep' ? 'deliver' : 'skip';
68
84
  return 'deliver';
69
85
  }
70
86
  //# sourceMappingURL=NovelCoverPolicy.js.map
@@ -132,6 +132,7 @@ class DownloadManager {
132
132
  : MaterializationPolicy_1.DEFAULT_MATERIALIZATION_POLICY;
133
133
  const novelCoverPolicy = {
134
134
  unknownCover: config.download?.novelCover?.unknown ?? NovelCoverPolicy_1.DEFAULT_NOVEL_COVER_POLICY.unknownCover,
135
+ probeFailed: config.download?.novelCover?.probeFailed ?? NovelCoverPolicy_1.DEFAULT_NOVEL_COVER_POLICY.probeFailed,
135
136
  };
136
137
  this.novelDownloader = new NovelDownloader_1.NovelDownloader(client, database, fileService, database, undefined, materialization, novelCoverPolicy);
137
138
  this.planner = new DownloadPlanner_1.DownloadPlanner(database, {
@@ -34,8 +34,11 @@ export declare class NovelDownloader {
34
34
  * - unknown → policy decision, default 'skip' (safe mode), so a future
35
35
  * Pixiv cover-format change surfaces as a loud
36
36
  * `coverType=unknown` log instead of leaking silently
37
- * A FAILED probe (network / auth / rate limit) is a separate case and always
38
- * keeps the cover: a transient fetch error must never cost a real one.
37
+ * - probe_failed → policy decision, default 'skip': the bytes were never
38
+ * seen, and most novel covers are generated designs, so
39
+ * keeping an unseen cover re-ships what this classifier
40
+ * exists to suppress. `download.novelCover.probeFailed:
41
+ * keep` restores the availability-first behaviour.
39
42
  */
40
43
  private resolveCoverUrl;
41
44
  }
@@ -418,8 +418,11 @@ class NovelDownloader {
418
418
  * - unknown → policy decision, default 'skip' (safe mode), so a future
419
419
  * Pixiv cover-format change surfaces as a loud
420
420
  * `coverType=unknown` log instead of leaking silently
421
- * A FAILED probe (network / auth / rate limit) is a separate case and always
422
- * keeps the cover: a transient fetch error must never cost a real one.
421
+ * - probe_failed → policy decision, default 'skip': the bytes were never
422
+ * seen, and most novel covers are generated designs, so
423
+ * keeping an unseen cover re-ships what this classifier
424
+ * exists to suppress. `download.novelCover.probeFailed:
425
+ * keep` restores the availability-first behaviour.
423
426
  */
424
427
  async resolveCoverUrl(novelId, coverUrl) {
425
428
  const normalized = (0, novelCover_1.normalizeNovelCoverUrl)(coverUrl);
@@ -430,13 +433,29 @@ class NovelDownloader {
430
433
  cover = await this.client.downloadImage(normalized);
431
434
  }
432
435
  catch (error) {
433
- logger_1.logger.warn(`Novel ${novelId} cover probe failed; keeping the cover (coverType=probe_failed)`, {
436
+ const reason = error instanceof Error ? error.message : String(error);
437
+ // A failed probe is a policy decision, not an automatic keep: most novel
438
+ // covers ARE Pixiv's generated designs, so silently shipping an unseen
439
+ // cover re-ships exactly what the 640x900 classifier exists to suppress.
440
+ const probeDecision = (0, NovelCoverPolicy_1.coverDeliveryDecision)(this.novelCoverPolicy, 'probe_failed');
441
+ if (probeDecision === 'deliver') {
442
+ logger_1.logger.warn(`Novel ${novelId} cover probe failed; keeping the cover per novelCover.probeFailed=keep (coverType=probe_failed)`, {
443
+ novelId,
444
+ coverUrl: normalized,
445
+ coverType: 'probe_failed',
446
+ policy: this.novelCoverPolicy.probeFailed,
447
+ reason,
448
+ });
449
+ return normalized;
450
+ }
451
+ logger_1.logger.warn(`Novel ${novelId} cover probe failed; skipping the cover per novelCover.probeFailed=skip (coverType=probe_failed)`, {
434
452
  novelId,
435
453
  coverUrl: normalized,
436
454
  coverType: 'probe_failed',
437
- reason: error instanceof Error ? error.message : String(error),
455
+ policy: this.novelCoverPolicy.probeFailed,
456
+ reason,
438
457
  });
439
- return normalized;
458
+ return null;
440
459
  }
441
460
  const coverType = (0, NovelCoverPolicy_1.classifyNovelCover)(cover);
442
461
  const decision = (0, NovelCoverPolicy_1.coverDeliveryDecision)(this.novelCoverPolicy, coverType);
@@ -4,6 +4,7 @@ exports.NotificationPolicy = void 0;
4
4
  const DeliveryService_1 = require("../delivery/DeliveryService");
5
5
  const targetRoutes_1 = require("../delivery/targetRoutes");
6
6
  const TargetOutcome_1 = require("../scheduler/TargetOutcome");
7
+ const ProtocolErrors_1 = require("../scheduler/ProtocolErrors");
7
8
  const SlotCoordinator_1 = require("../scheduler/SlotCoordinator");
8
9
  const logger_1 = require("../logger");
9
10
  /**
@@ -227,6 +228,20 @@ class NotificationPolicy {
227
228
  const name = this.targetName(target);
228
229
  if (!name)
229
230
  return;
231
+ // A consumer/operator cancel is NOT a refetch failure (finding D). The
232
+ // cancelled cell keeps its terminal `cancelled_by_consumer` verdict, and no
233
+ // `disposition:"failed"` outcome may ever be emitted for it — the operator
234
+ // deliberately stopped the work, and the cancellation is already surfaced
235
+ // through the job status / events channel, never as a failed refetch report.
236
+ const cancelledCell = target.id ? this.database.slots.getCell(slot.slotId, target.id) : null;
237
+ if (cancelledCell?.terminalReasonCode === ProtocolErrors_1.CANCELLED_BY_CONSUMER) {
238
+ logger_1.logger.info('Refetch outcome suppressed: job was cancelled by the consumer', {
239
+ slot: slot.slotId,
240
+ target: target.id,
241
+ requestId,
242
+ });
243
+ return;
244
+ }
230
245
  const deliveryTarget = this.config.delivery?.targets?.[name];
231
246
  if (!deliveryTarget || deliveryTarget.type !== 'httpMultipart')
232
247
  return;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "pixivflow",
4
- "version": "3.4.1",
4
+ "version": "3.4.2",
5
5
  "private": true
6
6
  }
@@ -245,6 +245,13 @@ class SlotCoordinator {
245
245
  const cell = this.database.slots.getCell(slotId, targetId);
246
246
  if (!cell)
247
247
  return;
248
+ // A consumer/operator cancel is FINAL (see JobCancellation.ts). The abort of
249
+ // the interrupted run still lands here through the normal per-target outcome
250
+ // path; a late `failed` must never re-verdict a cancelled cell, or the
251
+ // protocol status flips from `cancelled` back to `failed` ~10s after the
252
+ // operator's cancel (finding D). Cancel verdicts are never re-written.
253
+ if (cell.terminalReasonCode === ProtocolErrors_1.CANCELLED_BY_CONSUMER)
254
+ return;
248
255
  switch (outcome.kind) {
249
256
  case 'submitted':
250
257
  this.database.slots.lockCellWork(slotId, targetId, outcome.workId, outcome.workType);
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BUILD = void 0;
4
4
  // GENERATED by scripts/write-version.js — do not edit manually.
5
- exports.BUILD = { version: '3.4.1', commit: 'd2e9c9e338bd' };
5
+ exports.BUILD = { version: '3.4.2', commit: '4db0bf21a785' };
6
6
  //# sourceMappingURL=version.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "commonjs",
3
3
  "name": "pixivflow-webui-backend",
4
- "version": "3.4.1",
4
+ "version": "3.4.2",
5
5
  "description": "PixivFlow WebUI Backend - CommonJS module"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixivflow",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "description": "🎨 Pixiv 下载、筛选与自动收集工具 - 批量下载插画和小说、按标签/热度/日期筛选、定时任务与可靠 HTTP 交付 | Pixiv downloader and automation toolkit with filtering, scheduling and reliable HTTP delivery",
5
5
  "repository": {
6
6
  "type": "git",