Skip to content

Commit 4a2d7ff

Browse files
dalkiaclaude
andcommitted
refactor: rename HasDepsDigests to HasCanonicalAssets
The flag signals what the converter actually guarantees: only scenes fetch files[], and only scene bundles upload to the canonical assets/ prefix (asset-reuse is gated on entity.type === 'scene'). The name now says so, and the flag fires for any injected files[] — a reuse-converted scene can legitimately list only 2-part names and still live under assets/. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 166c9a3 commit 4a2d7ff

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

Explorer/Assets/DCL/Infrastructure/ECS/Unity/StreamableLoading/AssetBundles/PrepareAssetBundleLoadingParametersSystemBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ private URLAddress GetAssetBundleURL(AssetBundleManifestVersion manifest, string
8383
{
8484
string version = manifest.GetAssetBundleManifestVersion();
8585

86-
// Digest-mapped bundles live under the canonical assets/ prefix (no entity segment) — requesting it
87-
// directly skips the edge rewrite. Manifests without the map (wearables/emotes, pre-v49 scenes) carry
88-
// digest-less hashes that only resolve through the entity path, so they keep the legacy shapes.
89-
if (manifest.HasDepsDigests())
86+
// Canonical-assets bundles live under the assets/ prefix (no entity segment) — requesting it directly
87+
// skips the edge rewrite. Entity-scoped bundles (wearables/emotes, pre-v49 scenes) only resolve through
88+
// the entity path, so they keep the legacy shapes.
89+
if (manifest.HasCanonicalAssets())
9090
return assetBundlesURL.Append(new URLPath($"{version}/assets/{hash}"));
9191

9292
if (manifest.HasHashInPath())

Explorer/Assets/DCL/Infrastructure/ECS/Unity/StreamableLoading/AssetBundles/Tests/EditModeTests/DepsDigestCacheKeyShould.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,19 @@ public void TranslateBareHashCaseInsensitivelyToManifestCasing()
5757
}
5858

5959
[Test]
60-
public void ReportDepsDigestsOnlyWhenMapWasInjected()
60+
public void ReportCanonicalAssetsOnlyWhenFilesWereInjected()
6161
{
62-
// The cache-key dispatch hinges on this: only scene manifests receive files[]; wearables/emotes must keep buildDate keying.
63-
var withoutMap = AssetBundleManifestVersion.CreateFromFallback("v49", "2026-05-01");
64-
Assert.That(withoutMap.HasDepsDigests(), Is.False);
62+
// The URL shape and cache-key dispatch hinge on this: only scenes fetch files[], and only scene bundles
63+
// are stored under the canonical assets/ prefix; wearables/emotes must keep entity-path URLs and buildDate keying.
64+
var withoutFiles = AssetBundleManifestVersion.CreateFromFallback("v49", "2026-05-01");
65+
Assert.That(withoutFiles.HasCanonicalAssets(), Is.False);
6566

66-
AssetBundleManifestVersion withMap = CreateV49Manifest($"{HASH_A}_{DIGEST_A}_mac");
67-
Assert.That(withMap.HasDepsDigests(), Is.True);
67+
AssetBundleManifestVersion withDigestFiles = CreateV49Manifest($"{HASH_A}_{DIGEST_A}_mac");
68+
Assert.That(withDigestFiles.HasCanonicalAssets(), Is.True);
6869

69-
// A manifest whose files[] contained only legacy 2-part names carries no map either.
70+
// Any injected files[] counts — a reuse-converted scene can legitimately list only 2-part names.
7071
AssetBundleManifestVersion onlyLegacyFiles = CreateV49Manifest($"{HASH_LEGACY}_mac");
71-
Assert.That(onlyLegacyFiles.HasDepsDigests(), Is.False);
72+
Assert.That(onlyLegacyFiles.HasCanonicalAssets(), Is.True);
7273
}
7374

7475
[Test]
@@ -107,7 +108,7 @@ public void ResolveQmContentCasingThroughTheSameMap()
107108
manifest.InjectContent("Qmf7DaJZRygoayfNn5Jq6QAykrhFpQUr2us2VFvjREiajk",
108109
new[] { new ContentDefinition { file = "model.glb", hash = "QmaBrb8WisG9b4Szzt6ACHgaJdyULTEjpzmTwDi4RCEtZV" } });
109110

110-
Assert.That(manifest.HasDepsDigests(), Is.False, "Content casing entries must not switch cache keying to the v49 scheme");
111+
Assert.That(manifest.HasCanonicalAssets(), Is.False, "Content casing entries must not switch the URL shape or cache keying to the canonical scheme");
111112

112113
Assert.That(manifest.GetCdnRequestHash("QmaBrb8WisG9b4Szzt6ACHgaJdyULTEjpzmTwDi4RCEtZV"),
113114
Is.EqualTo($"qmabrb8wisg9b4szzt6achgajdyultejpzmtwdi4rcetzv{platform}").IgnoreCase);

Explorer/Assets/DCL/NetworkDefinitions/AssetBundleManifestVersion.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AssetBundleManifestVersion
3636

3737
//Bare hash → canonical CDN file name; fed by InjectDepsDigests (digest-bearing names) and InjectContent (Qm casing fixes).
3838
private Dictionary<string, string>? cdnFiles;
39-
private bool hasDepsDigests;
39+
private bool hasCanonicalAssets;
4040

4141
public bool HasHashInPath()
4242
{
@@ -76,6 +76,7 @@ private static bool TryParseVersionNumber(string? version, out int parsed)
7676
public void InjectDepsDigests(string[]? files)
7777
{
7878
if (files == null || files.Length == 0) return;
79+
hasCanonicalAssets = true;
7980

8081
foreach (string file in files)
8182
{
@@ -86,13 +87,12 @@ public void InjectDepsDigests(string[]? files)
8687

8788
cdnFiles ??= new Dictionary<string, string>(new UrlHashComparer());
8889
cdnFiles[parts[0]] = file;
89-
hasDepsDigests = true;
9090
}
9191
}
9292

93-
/// <summary>True when digest-bearing files were injected — only scene manifests fetch <c>files[]</c>; wearables/emotes never do and keep buildDate cache keying.</summary>
94-
public bool HasDepsDigests() =>
95-
hasDepsDigests;
93+
/// <summary>True when the manifest's <c>files[]</c> were injected — only scenes fetch them, and only scene bundles are stored under the canonical <c>assets/</c> prefix. Wearables/emotes stay entity-scoped and keep buildDate cache keying.</summary>
94+
public bool HasCanonicalAssets() =>
95+
hasCanonicalAssets;
9696

9797
/// <summary>Translates a bare hash to the hash requested from the CDN: the canonical manifest file name when known (digest-bearing, correctly cased), otherwise the platform-suffixed bare hash.</summary>
9898
public string GetCdnRequestHash(string bareHash) =>
@@ -102,9 +102,9 @@ public string GetCdnRequestHash(string bareHash) =>
102102
public string ComposeCacheKey(string hash) =>
103103
TryGetCdnFileName(hash, out string fileName) ? fileName : hash;
104104

105-
/// <summary>Computes the Unity-cache key for a CDN request hash: scene manifests (deps map present) key on version+hash — the digest travels inside the hash — while wearables/emotes keep buildDate keying, as their bundles are republished in place.</summary>
105+
/// <summary>Computes the Unity-cache key for a CDN request hash: canonical-assets manifests key on version+hash — the digest travels inside the hash — while wearables/emotes keep buildDate keying, as their bundles are republished in place.</summary>
106106
public Hash128 ComputeCacheHash(string hash) =>
107-
HasDepsDigests()
107+
HasCanonicalAssets()
108108
? ComputeHashV49(hash, GetAssetBundleManifestVersion()!)
109109
: ComputeHashLegacy(hash, GetAssetBundleManifestBuildDate()!);
110110

0 commit comments

Comments
 (0)