Skip to content

[eas-cli] Skip rewriting unchanged screenshots in metadata:pull#3846

Open
ahmdshrif wants to merge 1 commit into
expo:mainfrom
ahmdshrif:fix-metadata-pull-screenshot-rewrite
Open

[eas-cli] Skip rewriting unchanged screenshots in metadata:pull#3846
ahmdshrif wants to merge 1 commit into
expo:mainfrom
ahmdshrif:fix-metadata-pull-screenshot-rewrite

Conversation

@ahmdshrif

Copy link
Copy Markdown

Why

Fixes #3804.

Running eas metadata:pull marks every downloaded screenshot as changed on each invocation, even when nothing about the image changed. App Store Connect embeds a unique asset resource ID into each screenshot's eXIf (UserComment) and iTXt (Adobe XMP) PNG chunks on every download, so the downloaded bytes always differ from the local file — while the decoded image (IDAT) is byte-for-byte identical. downloadScreenshotAsync writes the response buffer unconditionally, so every pull dirties version control with meaningless diffs.

How

  • Added isPngEquivalent(a, b) in metadata/utils/png.ts: walks both buffers' PNG chunk sequences and compares them ignoring the volatile metadata chunks (tEXt, zTXt, iTXt, eXIf, tIME). All other chunks — including all pixel data — must match exactly. Falls back to plain byte equality when either buffer is not a structurally valid PNG, so non-PNG assets keep today's behavior.
  • In downloadScreenshotAsync, when a local file already exists at the output path, the write is skipped if the existing file is PNG-equivalent to the downloaded buffer (logged as Screenshot unchanged). The config entry still points at the same relative path, so metadata.json/sync behavior is unchanged.

No new dependencies — the chunk walk is ~30 lines over the documented PNG structure (8-byte signature + length/type/data/CRC chunks).

Test Plan

  • yarn test src/metadata — 16 suites, 195 tests pass, including:
    • new unit tests for isPngEquivalent (metadata/utils/__tests__/png.test.ts): equivalent when only iTXt/eXIf/tEXt differ, not equivalent when IDAT/PLTE differ, byte-equality fallback for non-PNG buffers, truncated-PNG safety;
    • new task test (screenshots.test.ts): a pull where the local file differs from the download only in the iTXt chunk does not call fs.promises.writeFile, and still writes the config entry.
  • yarn lint, yarn fmt:check, yarn typecheck — clean (remaining warnings/errors are pre-existing on main and untouched by this PR).
  • Manual reproduction: run eas metadata:pull twice in a git-tracked project with existing screenshots — before this change every screenshot shows as modified on the second pull; after, git status stays clean.

@github-actions

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @douglowder
packages/eas-cli/src/metadata/** @byCedric

Generated by CodeMention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metadata:pull rewrites screenshots with identical ones

1 participant