Skip to content

Preserve duplicate WebView asset paths#281

Open
CR29-22-2805 wants to merge 1 commit into
reddit:mainfrom
CR29-22-2805:preserve-duplicate-webview-paths
Open

Preserve duplicate WebView asset paths#281
CR29-22-2805 wants to merge 1 commit into
reddit:mainfrom
CR29-22-2805:preserve-duplicate-webview-paths

Conversation

@CR29-22-2805

Copy link
Copy Markdown

Fixes #280

💸 TL;DR

This PR preserves every original WebView asset path in webViewAssetMap when multiple files have identical contents.

Identical assets are still uploaded only once, but each duplicate file path now maps to the shared uploaded URL.

📜 Details

AssetUploader already detects WebView assets with matching hashes and sizes and avoids uploading duplicate contents more than once.

However, only the path of the unique uploaded asset was added to webViewAssetMap. Other files with the same contents were classified as duplicates but omitted from the final map.

For example, two identical files:

client/header-logo.svg
client/footer-logo.svg

could result in a map containing only one path.

This PR:

  • Records the uploaded URL for each unique asset signature.
  • Adds every duplicate WebView asset path to webViewAssetMap.
  • Maps duplicate paths to the same URL as the corresponding uploaded asset.
  • Preserves the existing single-upload behavior for identical contents.
  • Replaces the repeated newAssets.find(...) duplicate lookup with a signature-based Set.

The asset signature continues to use the asset hash and size, matching the existing duplicate-classification behavior.

🧪 Testing Steps / Validation

Added regression coverage for two WebView assets that have:

  • Different file paths.
  • Identical contents.
  • The same asset hash and size.

The test verifies that:

  • The upload endpoint is called only once.
  • Both original file paths appear in webViewAssetMap.
  • Both paths resolve to the same uploaded URL.

Validation completed:

  • git diff --check

Focused test to run:

yarn vitest packages/cli/src/util/AssetUploader.test.ts --run

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@CR29-22-2805
CR29-22-2805 requested a review from a team as a code owner July 20, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Preserve duplicate WebView asset paths when deduplicating uploads

1 participant