toXlsx: the same input gives a different file on every call (zip timestamps)

Offen Anfängerfreundlich
#163 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript

Rechercherichtung

Lies packages/pivotkit-core/src/xlsx.js um Zeile 250 herum und prüfe die Zip-Optionen von fflate für das Feld der Änderungszeit. Füge die Option modified zu toXlsx hinzu und übergib sie an jeden Zip-Eintrag; verwende in Tests ein festes Datum. Fertig ist die Änderung, wenn wiederholte Aufrufe mit demselben Raster und derselben Änderungszeit identische Dateibytes erzeugen, während der Inhalt der Arbeitsmappe unverändert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area:core enhancement

toXlsx produces a different file on every call for the same input, because the zip entries carry the current time. A workbook can't be compared by hash, and a scheduled report sends a "changed" file even when the data did not change.

Where: packages/pivotkit-core/src/xlsx.js line 250 calls zipSync(zipped, { level: 6 }) without a modification time, so fflate stamps each entry with the time of the call.

Not affected: the workbook content. Unzipped, every entry is byte-identical between runs; Excel and other readers don't care about the timestamps. Nothing has broken so far because no test or feature compares whole files.

Reproduce: call toXlsx twice on the same grid, compare SHA-256 of the two results: they differ; compare the unzipped entries: they match.

Fix: an option such as toXlsx(grid, { modified }) (a Date) that is passed as mtime to every zip entry, with a fixed default in tests. Check fflate's zip options for the exact field before building it. The headless report runner would pass the run's fire time, so a rerun of the same report gives the same bytes.

Found while probing headless runtimes for scheduled reports.

Vorherrschende Sprache
JavaScript
Sterne
1
Forks
1
Ø Merge
3 Std. 21 Min.
Gemergte PRs (30 T.)
250

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus eizedev/pivotkit

Alle Issues in eizedev/pivotkit

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.