Thumbnail logo detection ignores logos already recorded in manifest.shared

Ouverte Adaptée aux débutants
#246 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
84/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
javascript, node.js
Domaine
backend, data

Piste de recherche

Lis la boucle de dépôt des logos partagés dans site/thumbs.mjs:311-318 et sharedImageIds dans site/lib/thumbs.mjs:162-172, puis examine le test existant de sharedImageIds dans site/lib/lib.test.mjs. Ajoute un test pour un nouvel enregistrement dont le hash existe déjà dans shared, puis exécute npm test. Le travail est terminé lorsque le nouvel enregistrement est déplacé vers shared et que le test réussit.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug good first issue priority: medium

Summary

The three-or-more shared-hash rule that keeps publisher logos out of thumbnails only counts records fetched in the current run, so a logo that was already dropped into manifest.shared is accepted again when a single new entry from the same site is fetched.

Where

  • site/thumbs.mjs:311-318 (logo drop loop)
  • site/thumbs.mjs:263-266 (shared skip)
  • site/lib/thumbs.mjs:162-172 (sharedImageIds)

Details

for (const id of sharedImageIds(thumbs)) {   // counts hashes in `thumbs` only
  shared[id] = thumbs[id];
  delete thumbs[id];
  pending.delete(id);
}
for (const id of Object.keys(thumbs)) delete shared[id];

Records dropped in an earlier run live in shared, not thumbs, so they never count toward the limit again. The existing test (site/lib/lib.test.mjs, the sharedImageIds case) only covers three records sitting in thumbs together.

Impact

A publisher's site-wide logo or social card is published as an asset preview with a "Preview image shown under " credit, which is the case the shared-hash rule (#132) exists to block.

Steps to reproduce

  1. Entries A, B and C on one site share an og:image; a run drops them into manifest.shared.
  2. Add entry D from the same site (or change A's url).
  3. Run node site/thumbs.mjs: D's image hash appears once in thumbs, below the limit, so D keeps the logo. Pure check: sharedImageIds({ D: { hash: "h" } }) is empty even when shared holds three records with hash h.

Suggested fix

Count hashes across { ...shared, ...thumbs } and drop only the ids that are in thumbs; or keep a set of known logo hashes and reject any fetched image whose hash is in it.

Acceptance criteria

  • A newly fetched record whose hash matches a hash already in shared is moved to shared
  • Unit test: one new record plus an already recorded shared hash

Getting started

  • Relevant files: site/thumbs.mjs, site/lib/thumbs.mjs, site/lib/lib.test.mjs
  • Run the tests: npm test; the full local gate is npm run check (Node 22+, no install step)
  • Related docs: CONTRIBUTING.md, site/README.md

Related: #232, #132


Filed by repo-audit/full-audit at 4adb944. Severity: medium. Effort: S. audit-key: bug|site/thumbs.mjs|sharedImageIds

Langage dominant
JavaScript
Étoiles
58
Forks
15
Merge moyen
1 j 15 h
PR mergées (30 j)
12

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TMHSDigital/Free-Game-Dev-Assets

Toutes les issues de TMHSDigital/Free-Game-Dev-Assets

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.