Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Analyzer/SQLite/Handlers/AssetBundleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void Process(Context ctx, long objectId, RandomAccessReader reader, out s
// Scriptable Build Pipeline / Addressables: key the scene on its SerializedFile
// (from m_SceneHashes) and create the synthetic Scene object here, since the writer
// cannot recognise a "CAB-<hash>" scene file by name.
var sceneFileId = ctx.SerializedFileIdProvider.GetId(sceneFile.ToLowerInvariant());
var sceneFileId = ctx.SerializedFileIdProvider.GetId(sceneFile);
var objId = ctx.ObjectIdProvider.GetId((sceneFileId, 0));

// The synthetic Scene object is inserted once (objects.id is a primary key), but the
Expand Down
6 changes: 3 additions & 3 deletions Analyzer/SQLite/Writers/ContentLayoutSQLWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ private void PopulateContentFileDependencies(ContentLayout layout)

var resolved = (file.SerializedFileDependencies ?? [])
.Select(i => hashByIndex.TryGetValue(i, out var hash) && !string.IsNullOrEmpty(hash)
? (hash + ".cf").ToLowerInvariant()
? hash + ".cf"
: null)
.ToArray();

m_ContentFileDependencies.Add((file.ContentHash + ".cf").ToLowerInvariant(), resolved);
m_ContentFileDependencies.Add(file.ContentHash + ".cf", resolved);
}
}

Expand Down Expand Up @@ -246,7 +246,7 @@ public void LinkSerializedFiles()
{
foreach (var file in m_ImportedFiles)
{
var fileName = (file.ContentHash + ".cf").ToLowerInvariant();
var fileName = file.ContentHash + ".cf";
var id = m_SerializedFileIdProvider.GetId(fileName);

update.Parameters["@id"].Value = id;
Expand Down
17 changes: 9 additions & 8 deletions Analyzer/SQLite/Writers/SerializedFileSQLiteWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con
using var sf = UnityFileSystem.OpenSerializedFile(fullPath);
using var reader = new UnityFileReader(fullPath, 64 * 1024 * 1024);
using var pptrReader = new PPtrAndCrcProcessor(sf, reader, containingFolder, m_SkipCrc, AddReference);
int serializedFileId = m_SerializedFileIdProvider.GetId(Path.GetFileName(fullPath).ToLowerInvariant());
int serializedFileId = m_SerializedFileIdProvider.GetId(Path.GetFileName(fullPath));
int sceneId = -1;

// Two SerializedFiles with the same name map to the same id (the provider deduplicates by
Expand Down Expand Up @@ -244,7 +244,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con
// path -> file mapping from the AssetBundle object's m_SceneHashes.
var fileName = Path.GetFileName(fullPath);
var sceneFileName = fileName.Substring(0, fileName.Length - ".sharedAssets".Length);
var sceneFileId = m_SerializedFileIdProvider.GetId(sceneFileName.ToLowerInvariant());
var sceneFileId = m_SerializedFileIdProvider.GetId(sceneFileName);
sceneId = m_ObjectIdProvider.GetId((sceneFileId, 0));
}

Expand Down Expand Up @@ -272,12 +272,13 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con

// Local file id 0 is always this file itself; ids 1..N follow the order of the
// external reference table. Resolve each external reference to its global file id
// by (lowercased) file name. For ContentDirectory files the external table holds
// symbolic placeholders, so when an imported ContentLayout covers this file the
// actual target comes from its dependency list, matched by position; built-in
// dependencies (null entries) keep the external table path.
// by file name (matched case-sensitively, as it appears on disk / in the archive).
// For ContentDirectory files the external table holds symbolic placeholders, so when
// an imported ContentLayout covers this file the actual target comes from its
// dependency list, matched by position; built-in dependencies (null entries) keep the
// external table path.
var resolvedDependencies = m_ContentFileDependencies.GetDependencies(
Path.GetFileName(fullPath).ToLowerInvariant());
Path.GetFileName(fullPath));

if (resolvedDependencies != null && resolvedDependencies.Length != sf.ExternalReferences.Count)
{
Expand All @@ -292,7 +293,7 @@ public void WriteSerializedFile(string relativePath, string fullPath, string con
foreach (var extRef in sf.ExternalReferences)
{
var name = resolvedDependencies?[localId - 1]
?? extRef.Path.Substring(extRef.Path.LastIndexOf('/') + 1).ToLowerInvariant();
?? extRef.Path.Substring(extRef.Path.LastIndexOf('/') + 1);
m_LocalToDbFileId.Add(localId++, m_SerializedFileIdProvider.GetId(name));
}

Expand Down
8 changes: 4 additions & 4 deletions Analyzer/Util/ContentFileDependencyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace UnityDataTools.Analyzer.Util;
// In ContentDirectory builds the external reference table inside a SerializedFile holds symbolic
// .cfid placeholders instead of real filenames; the actual target of a reference is determined
// positionally through the layout's dependency list (see Documentation/contentdirectory-format.md).
// This map holds, for each content file (keyed by its lowercased "<contenthash>.cf" filename),
// the resolved dependency filenames in external-reference-table order. An entry is null where the
// This map holds, for each content file (keyed by its "<contenthash>.cf" filename), the resolved
// dependency filenames in external-reference-table order. An entry is null where the
// dependency is a built-in file (which has no content hash); such references fall back to the
// path from the external reference table.
public class ContentFileDependencyMap
Expand All @@ -19,8 +19,8 @@ public void Add(string fileName, string[] resolvedDependencies)
m_Dependencies[fileName] = resolvedDependencies;
}

// Returns the resolved dependency filenames for the given (lowercased) filename, or null if
// the file is not covered by an imported ContentLayout.
// Returns the resolved dependency filenames for the given filename, or null if the file is
// not covered by an imported ContentLayout.
public string[] GetDependencies(string fileName)
{
return m_Dependencies.TryGetValue(fileName, out var dependencies) ? dependencies : null;
Expand Down
Loading