Skip to content

Commit 5d22bad

Browse files
[149] Cover dotted folder names in the AssetBundle variant check
1 parent 82743f9 commit 5d22bad

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎Analyzer/SQLite/Writers/SerializedFileSQLiteWriter.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ public void EndArchive()
180180
// AssetBundle variants are named "<bundle>.<variant>", and every variant of a bundle contains
181181
// a SerializedFile with the same name. Two archives that differ only in their extension and
182182
// share a SerializedFile are therefore taken to be variants of the same bundle.
183+
//
184+
// The names are paths, and the Path methods below only consider the last segment, so a dot in
185+
// a folder name ("v1.2/main") is not mistaken for a variant suffix.
183186
private static bool LooksLikeAssetBundleVariantPair(string archiveA, string archiveB)
184187
{
185188
if (archiveA == null || archiveB == null || archiveA == archiveB)

‎UnityDataTool.Tests/AnalyzeDuplicateNameTests.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,30 @@ public async Task Analyze_FileNamedDirectly_KeepsBareFileName()
214214
SQLTestHelper.AssertQueryString(db, "SELECT name FROM archives", "main",
215215
"a directly-named archive keeps its bare file name");
216216
}
217+
218+
// The variant check compares the extensions of two archive names, which are now paths. A dot
219+
// in a folder name is not an extension, so two bundles under "v1.2" and "v1.3" must be
220+
// reported as a plain duplicate rather than as variants of each other.
221+
[Test]
222+
public async Task Analyze_DottedFolderNames_NotReportedAsVariants()
223+
{
224+
var source = Path.Combine(m_AssetBundlesFolder, "2019.4.0f1", "assetbundle");
225+
foreach (var folder in new[] { "v1.2", "v1.3" })
226+
{
227+
Directory.CreateDirectory(Path.Combine(m_TestOutputFolder, folder));
228+
File.Copy(source, Path.Combine(m_TestOutputFolder, folder, "main"));
229+
}
230+
var databasePath = SQLTestHelper.GetDatabasePath(m_TestOutputFolder);
231+
232+
var (exitCode, stderr) = await RunAnalyze(m_TestOutputFolder, "-o", databasePath);
233+
234+
Assert.AreEqual(0, exitCode);
235+
StringAssert.Contains("Duplicate SerializedFile name", stderr);
236+
StringAssert.DoesNotContain("AssetBundle variant", stderr);
237+
238+
using var db = SQLTestHelper.OpenDatabase(databasePath);
239+
SQLTestHelper.AssertQueryInt(db,
240+
"SELECT COUNT(*) FROM archives WHERE name IN ('v1.2/main', 'v1.3/main')",
241+
2, "both archives should be recorded under their dotted-folder relative path");
242+
}
217243
}

0 commit comments

Comments
 (0)