diff --git a/doc/DataSync.md b/doc/DataSync.md index 13da5c1..499fead 100644 --- a/doc/DataSync.md +++ b/doc/DataSync.md @@ -116,7 +116,14 @@ umap files on the shared drive. Again, you can't have any uncommitted changes to umap files. In the same way as push, the script uses the OID of the umap file to look up -the versions on the shared drive. If the matching OID file exists, and +the versions on the shared drive. However, if a lighting build with that +OID doesn't exist, pull checks the git log and finds the latest lighting build +available for that umap file. This is to deal with the case where changes have +been made to the umap file since the last lighting build, but the lighting build +is still OK to use (either the umap changes didn't affect lighting, or the +differences are "good enough" for the moment). + +If an appropriate BuiltData file is found on the shared drive, and you don't have a newer local version, then the BuiltData file is copied into place in your local project folder. Next time you open the editor you'll have the lighting data that your team mate built. diff --git a/ue4-datasync.ps1 b/ue4-datasync.ps1 index a40a4b1..e1085c2 100644 --- a/ue4-datasync.ps1 +++ b/ue4-datasync.ps1 @@ -57,6 +57,23 @@ function Get-Current-Umaps { } } +function Get-Remote-Builtdata-Path { + param ( + [string]$filename, + [string]$oid, + [string]$syncdir + ) + + $subdir = [System.IO.Path]::GetDirectoryName($filename) + $basename = [System.IO.Path]::GetFileNameWithoutExtension($filename) + + $remotesubdir = Join-Path $syncdir $subdir + $remotebuiltdata = Join-Path $remotesubdir "${basename}_BuiltData_${oid}.uasset" + + return $remotebuiltdata + +} + function Get-Builtdata-Paths { param ( [object]$umap, @@ -215,8 +232,47 @@ try { # In pull mode, we always pull if not same, or forced (checked already above) if (-not (Test-Path $remotebuiltdata -PathType Leaf)) { - Write-Warning "Skipping $filename, remote file missing" - continue + + # If we don't have lighting data for this specific OID, we + # look back at the file history of the umap and use the latest + # one that does exist instead. E.g. lighting build may have been done, then + # small changes made to the umap afterward which would stop it matching + # but the lighting build for the previous OID was fine + # We don't use the latest file because that could be ahead of us + $foundInHistory = $false + $logOutput = git log -p --oneline -- $filename + Write-Verbose "No data for $filename HEAD revision, checking for latest available" + foreach ($line in $logOutput) { + if ($line -match "^\+oid sha256:([0-9a-f]*)$") { + $logoid = $matches[1] + + # Ignore the latest one, we've already tried + if ($logoid -ne $oid) { + $testremotefile = Get-Remote-Builtdata-Path $filename $logoid $syncdir + + if (Test-Path $testremotefile -PathType Leaf) { + $foundInHistory = $true + $remotebuiltdata = $testremotefile + $oid = $logoid + Write-Verbose "Found latest for $filename ($logoid)" + break + } + } + } + } + + if ($foundInHistory) { + $same = Compare-Files-Quick $localbuiltdata $remotebuiltdata + + if ($same -and -not $force) { + Write-Verbose "Skipping $filename, matches" + continue + } + + } else { + Write-Warning "Skipping $filename, remote file missing" + continue + } } if ($dryrun) { @@ -226,7 +282,6 @@ try { New-Item -ItemType Directory $subdir -Force > $null Copy-Item $remotebuiltdata $localbuiltdata } - } }