3
3
[switch ]$Testing
4
4
)
5
5
6
- $CurrentScriptVersion = " 1.0.25 "
6
+ $CurrentScriptVersion = " 1.0.26 "
7
7
$global :HeaderWritten = $false
8
8
$ProgressPreference = ' SilentlyContinue'
9
9
@@ -1556,13 +1556,12 @@ function Rotate-Logs {
1556
1556
)
1557
1557
1558
1558
$logFolder = Join-Path $ScriptRoot " Logs"
1559
- $folderPattern = " Logs_*"
1560
- $RotationFolderName = " RotatedLogs"
1561
- $RotationFolder = Join-Path $ScriptRoot $RotationFolderName
1559
+ $global :RotationFolderName = " RotatedLogs"
1560
+ $RotationFolder = Join-Path $ScriptRoot $global :RotationFolderName
1562
1561
1563
1562
# Create Rotation Folder if missing
1564
1563
if (! (Test-Path - path $RotationFolder )) {
1565
- New-Item - ItemType Directory - Path $ScriptRoot - Name $RotationFolderName - Force | Out-Null
1564
+ New-Item - ItemType Directory - Path $ScriptRoot - Name $global : RotationFolderName - Force | Out-Null
1566
1565
}
1567
1566
1568
1567
# Check if the log folder exists
@@ -1572,7 +1571,7 @@ function Rotate-Logs {
1572
1571
Rename-Item - Path $logFolder - NewName " Logs`_$timestamp "
1573
1572
# Create Rotation Folder if missing
1574
1573
if (! (Test-Path $RotationFolder )) {
1575
- New-Item - ItemType Directory - Path $ScriptRoot - Name $RotationFolderName - Force | Out-Null
1574
+ New-Item - ItemType Directory - Path $ScriptRoot - Name $global : RotationFolderName - Force | Out-Null
1576
1575
}
1577
1576
# Move logs to Rotation Folder
1578
1577
Move-Item - Path " $logFolder `_$timestamp " $RotationFolder
@@ -1796,6 +1795,8 @@ $LatestScriptVersion = Get-LatestScriptVersion
1796
1795
# #### START #####
1797
1796
$startTime = Get-Date
1798
1797
# Rotate logs before doing anything!
1798
+ $folderPattern = " Logs_*"
1799
+ $global :RotationFolderName = $null
1799
1800
Rotate- Logs - ScriptRoot $global :ScriptRoot
1800
1801
Write-Log - Message " Starting..." - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Success
1801
1802
# Check if Config file is present
@@ -1825,10 +1826,12 @@ if ($maxLogs -le 0) {
1825
1826
$maxLogs = 1
1826
1827
}
1827
1828
# Delete excess log folders
1828
- $logFolders = Get-ChildItem - Path $ (Join-Path $global :ScriptRoot $RotationFolderName ) - Directory | Where-Object { $_.Name -match $folderPattern } | Sort-Object CreationTime - Descending | Select-Object - First $maxLogs
1829
- foreach ($folder in (Get-ChildItem - Path $ (Join-Path $global :ScriptRoot $RotationFolderName ) - Directory | Where-Object { $_.Name -match $folderPattern })) {
1829
+ $logFolders = Get-ChildItem - Path $ (Join-Path $global :ScriptRoot $global : RotationFolderName ) - Directory | Where-Object { $_.Name -match $folderPattern } | Sort-Object CreationTime - Descending | Select-Object - First $maxLogs
1830
+ foreach ($folder in (Get-ChildItem - Path $ (Join-Path $global :ScriptRoot $global : RotationFolderName ) - Directory | Where-Object { $_.Name -match $folderPattern })) {
1830
1831
if ($folder.FullName -notin $logFolders.FullName ) {
1831
1832
Remove-Item - Path $folder.FullName - Recurse - Force
1833
+ $fldrName = $folder.FullName
1834
+ Write-Log - Message " Deleting excess folder: $fldrName " - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Info
1832
1835
}
1833
1836
}
1834
1837
@@ -2042,11 +2045,13 @@ foreach ($path in $LogsPath, $TempPath, $TestPath, $AssetPath) {
2042
2045
# Delete all files and subfolders within the temp directory
2043
2046
if (Test-Path $TempPath ) {
2044
2047
Remove-Item - Path (Join-Path $TempPath ' *' ) - Recurse - Force
2048
+ Write-Log - Message " Deleting temp folder: $TempPath " - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Info
2045
2049
}
2046
2050
2047
2051
if ($Testing ) {
2048
2052
if ((Test-Path $TestPath )) {
2049
2053
Remove-Item - Path (Join-Path $TestPath ' *' ) - Recurse - Force
2054
+ Write-Log - Message " Deleting test folder: $TestPath " - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Info
2050
2055
}
2051
2056
}
2052
2057
@@ -2917,10 +2922,13 @@ Elseif ($Testing) {
2917
2922
$minutes = $executionTime.Minutes
2918
2923
$seconds = $executionTime.Seconds
2919
2924
$FormattedTimespawn = $hours.ToString () + " h " + $minutes.ToString () + " m " + $seconds.ToString () + " s "
2920
- Write-Log - Subtext " Poster/Background/TitleCard Tests finished, you can find them here: $ ( Join-Path $ global :ScriptRoot ' test ' ) " - Path ( Join-Path $global :ScriptRoot ' Logs\Testinglog .log' ) - Type Success
2921
- Write-Log - Message " Script execution time : $FormattedTimespawn " - Path $global :ScriptRoot \Logs\Testinglog .log - Type Success
2925
+ Write-Log - Subtext " Final cleanup starting... " - Path $global :ScriptRoot \ Logs\Scriptlog .log - Type Success
2926
+ Write-Log - Subtext " Deleting testimage : $testimage " - Path $global :ScriptRoot \Logs\Scriptlog .log - Type Info
2922
2927
Remove-Item - LiteralPath $testimage | out-null
2928
+ Write-Log - Subtext " Deleting backgroundtestimage: $backgroundtestimage " - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Info
2923
2929
Remove-Item - LiteralPath $backgroundtestimage | out-null
2930
+ Write-Log - Subtext " Poster/Background/TitleCard Tests finished, you can find them here: $ ( Join-Path $global :ScriptRoot ' test' ) " - Path (Join-Path $global :ScriptRoot ' Logs\Testinglog.log' ) - Type Success
2931
+ Write-Log - Message " Script execution time: $FormattedTimespawn " - Path $global :ScriptRoot \Logs\Testinglog.log - Type Success
2924
2932
$gettestimages = Get-ChildItem $global :ScriptRoot \test
2925
2933
$titlecardscount = ($gettestimages | Where-Object { $_.name -like ' Title*' }).count
2926
2934
$backgroundsscount = ($gettestimages | Where-Object { $_.name -like ' back*' }).count
@@ -3175,7 +3183,7 @@ else {
3175
3183
$SeasonNames = $SeasonsTemp.Title -join ' ,'
3176
3184
$SeasonNumbers = $SeasonsTemp.index -join ' ,'
3177
3185
$SeasonRatingkeys = $SeasonsTemp.ratingKey -join ' ,'
3178
- $SeasonPosterUrl = ($SeasonsTemp | where { $_.type -eq " season" }).thumb -join ' ,'
3186
+ $SeasonPosterUrl = ($SeasonsTemp | Where-Object { $_.type -eq " season" }).thumb -join ' ,'
3179
3187
}
3180
3188
$matchesimdb = [regex ]::Matches($metadatatemp , $imdbpattern )
3181
3189
$matchestmdb = [regex ]::Matches($metadatatemp , $tmdbpattern )
@@ -4607,6 +4615,7 @@ else {
4607
4615
}
4608
4616
if (Test-Path $EpisodeTempImage - ErrorAction SilentlyContinue) {
4609
4617
$null = Remove-Item - LiteralPath $EpisodeTempImage
4618
+ Write-Log - Message " Deleting EpisodeTempImage: $EpisodeTempImage " - Path $global :ScriptRoot \Logs\Scriptlog.log - Type Info
4610
4619
}
4611
4620
}
4612
4621
Else {
0 commit comments