Skip to content

Commit 0597384

Browse files
committed
Test for guid collision
1 parent ac24eb3 commit 0597384

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Test-UnityProjectInstanceMetaFileIntegrity .\MyUnityProject -PassThru
9595
# C:\MyUnityProject\Assets\SomeFolder Directory is missing associated meta file.
9696
# C:\MyUnityProject\Assets\SomeFolder\SomeShader.shader File is missing associated meta file.
9797
# C:\MyUnityProject\Assets\SomeFolder\SomeOtherShader.shader.meta Meta file is missing associated item.
98+
# C:\MyUnityProject\Assets\SomeFolder\SomeNewShader.shader.meta Meta file guid collision with C:\MyUnityProject\Assets\SomeFolder\SomeOtherShader.shader.meta
9899
```
99100

100101
Find the installers for a particular version:

UnitySetup/UnitySetup.psm1

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,9 @@ function Get-UnityProjectInstance {
13361336
.Synopsis
13371337
Tests the meta file integrity of the Unity Project Instance(s).
13381338
.DESCRIPTION
1339-
Tests if every item under assets has an associated .meta file and every .meta file an associated item.
1339+
Tests if every item under assets has an associated .meta file
1340+
and every .meta file an associated item
1341+
and that none of the meta file guids collide.
13401342
.PARAMETER Project
13411343
Unity Project Instance(s) to test the meta file integrity of.
13421344
.PARAMETER PassThru
@@ -1458,6 +1460,29 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14581460
}
14591461
}
14601462

1463+
if (-not $testResult) { $false; continue; }
1464+
1465+
Write-Verbose "Testing meta files for guid collisions..."
1466+
$metaGuids = @{ }
1467+
foreach ($metaFile in $metaFiles) {
1468+
$metaContent = Get-Content $metaFile.FullName -Raw | ConvertFrom-Yaml
1469+
if ($null -eq $metaGuids[$metaContent.guid]) {
1470+
$metaGuids[$metaContent.guid] = $metaFile;
1471+
continue
1472+
}
1473+
1474+
if ($PassThru) {
1475+
[PSCustomObject]@{
1476+
'Item' = $metaFile
1477+
'Issue' = "Meta file guid collision with $($metaGuids[$metaContent.guid])"
1478+
}
1479+
}
1480+
else {
1481+
$testResult = $false;
1482+
break;
1483+
}
1484+
}
1485+
14611486
if (-not $PassThru) { $testResult; }
14621487
}
14631488
}

0 commit comments

Comments
 (0)