Skip to content

Commit d2cbd09

Browse files
authored
Merge pull request #240 from jwittner/fix/metaFileIntegrityAssetFilters
Update filters for asset gathering
2 parents 0614dc7 + e101fff commit d2cbd09

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,9 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14681468
}
14691469
}
14701470

1471+
# Derived from https://docs.unity3d.com/Manual/SpecialFolders.html
1472+
$unityAssetExcludes = @('.*', '*~', 'cvs', '*.tmp')
1473+
14711474
foreach ( $p in $Project) {
14721475

14731476
$testResult = $true
@@ -1476,17 +1479,20 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
14761479
$assetDir = Join-Path $p.Path "Assets"
14771480

14781481
# get all the directories under assets
1479-
[System.IO.DirectoryInfo[]]$dirs = Get-ChildItem -Path "$assetDir/*" -Recurse -Directory -Exclude '.*'
1482+
[System.IO.DirectoryInfo[]]$dirs =
1483+
Get-ChildItem -Path "$assetDir/*" -Recurse -Directory -Exclude $unityAssetExcludes
14801484

14811485
Write-Verbose "Testing asset directories for missing meta files..."
14821486
[float]$progressCounter = 0
14831487
foreach ($dir in $dirs) {
14841488

1489+
++$progressCounter
14851490
$progress = @{
14861491
'Activity' = "Testing directories for missing meta files"
1487-
'Status' = $dir
1488-
'PercentComplete' = (((++$progressCounter) / $dirs.Length) * 100)
1492+
'Status' = "$progressCounter / $($dirs.Length) - $dir"
1493+
'PercentComplete' = (($progressCounter / $dirs.Length) * 100)
14891494
}
1495+
Write-Debug $progress.Status
14901496
Write-Progress @progress
14911497

14921498
$testPath = "$($dir.FullName).meta";
@@ -1507,20 +1513,24 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
15071513
if (-not $testResult) { $false; continue; }
15081514

15091515
# get all the non-meta files under assets
1510-
[System.IO.FileInfo[]]$files = Get-ChildItem -Path "$assetDir/*" -Exclude '.*', '*.meta' -File
1516+
$unityAssetFileExcludes = $unityAssetExcludes + '*.meta'
1517+
[System.IO.FileInfo[]]$files = Get-ChildItem -Path "$assetDir/*" -Exclude $unityAssetFileExcludes -File
15111518
foreach ($dir in $dirs) {
1512-
$files += Get-ChildItem -Path "$($dir.FullName)/*" -Exclude '.*', '*.meta' -File
1519+
$files += Get-ChildItem -Path "$($dir.FullName)/*" -Exclude $unityAssetFileExcludes -File
15131520
}
15141521

15151522
Write-Verbose "Testing asset files for missing meta files..."
15161523
$progressCounter = 0
15171524
foreach ( $file in $files ) {
15181525

1526+
++$progressCounter
15191527
$progress = @{
15201528
'Activity' = "Testing files for missing meta files"
1521-
'Status' = $file
1522-
'PercentComplete' = (((++$progressCounter) / $files.Length) * 100)
1529+
'Status' = "$progressCounter / $($files.Length) - $file"
1530+
'PercentComplete' = (($progressCounter / $files.Length) * 100)
1531+
15231532
}
1533+
Write-Debug $progress.Status
15241534
Write-Progress @progress
15251535

15261536
$testPath = "$($file.FullName).meta";
@@ -1541,7 +1551,7 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
15411551
if (-not $testResult) { $false; continue; }
15421552

15431553
$metaFileSearchArgs = @{
1544-
'Exclude' = '.*'
1554+
'Exclude' = $unityAssetExcludes
15451555
'Include' = '*.meta'
15461556
'File' = $true
15471557
'Force' = $true # Ensure we include hidden meta files
@@ -1557,11 +1567,13 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
15571567
$progressCounter = 0
15581568
foreach ($metaFile in $metaFiles) {
15591569

1570+
++$progressCounter
15601571
$progress = @{
15611572
'Activity' = "Testing meta files for missing assets"
1562-
'Status' = $metaFile
1563-
'PercentComplete' = (((++$progressCounter) / $metaFiles.Length) * 100)
1573+
'Status' = "$progressCounter / $($metaFiles.Length) - $metaFile"
1574+
'PercentComplete' = (($progressCounter / $metaFiles.Length) * 100)
15641575
}
1576+
Write-Debug $progress.Status
15651577
Write-Progress @progress
15661578

15671579
$testPath = $metaFile.FullName.SubString(0, $metaFile.FullName.Length - $metaFile.Extension.Length);
@@ -1586,11 +1598,13 @@ function Test-UnityProjectInstanceMetaFileIntegrity {
15861598
$progressCounter = 0
15871599
foreach ($metaFile in $metaFiles) {
15881600

1601+
++$progressCounter
15891602
$progress = @{
15901603
'Activity' = "Testing meta files for guid collisions"
1591-
'Status' = $metaFile
1592-
'PercentComplete' = (((++$progressCounter) / $metaFiles.Length) * 100)
1604+
'Status' = "$progressCounter / $($metaFiles.Length) - $metaFile"
1605+
'PercentComplete' = (($progressCounter / $metaFiles.Length) * 100)
15931606
}
1607+
Write-Debug $progress.Status
15941608
Write-Progress @progress
15951609

15961610
try {

0 commit comments

Comments
 (0)