Skip to content

Commit

Permalink
Add output for missing required fields after sort fail
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Sep 4, 2020
1 parent 7f453bf commit 59f185f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/Javinizer/Private/Test-JVData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ function Test-JVData {
$nullFields = $nullFields -join ', '
}

if ($errors -eq 0) {
$dataObject = [PSCustomObject]@{
Data = $Data
}
if ($nullFields.Count -eq 0) {
$nullFields = $null
}

Write-Output $dataObject
$dataObject = [PSCustomObject]@{
Data = $Data
NullFields = $nullFields
}

Write-Output $dataObject

}
}
6 changes: 3 additions & 3 deletions src/Javinizer/Public/Javinizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ function Javinizer {
return
}

$javData = Get-JVData -Url $Url -Settings $Settings
$javData = Get-JVData -Url $Url -Settings $Settings
if ($null -ne $javData) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
if ($null -ne $javAggregatedData) {
Expand All @@ -594,10 +594,10 @@ function Javinizer {
$javData = Get-JVData -Id $movie.Id -Settings $Settings
if ($null -ne $javData) {
$javAggregatedData = $javData | Get-JVAggregatedData -Settings $Settings | Test-JVData -RequiredFields $Settings.'sort.metadata.requiredfield'
if ($null -ne $javAggregatedData) {
if ($javAggregatedData.NullFields -eq '') {
$javAggregatedData | Set-JVMovie -Path $movie.FullName -DestinationPath $DestinationPath -Settings $Settings -PartNumber $movie.Partnumber -Force:$Force
} else {
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- missing required metadata fields"
Write-JVLog -Write:$script:JVLogWrite -LogPath $script:JVLogPath -WriteLevel $script:JVLogWriteLevel -Level Warning -Message "[$($movie.FileName)] Skipped -- missing required fields [$($javAggregatedData.NullFields)]"
return
}
} else {
Expand Down

0 comments on commit 59f185f

Please sign in to comment.