Skip to content

Commit

Permalink
fix: hashtable empty if using symlinks (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
fscorrupt authored Jan 16, 2025
2 parents 4ef3fb9 + d2ad45e commit ca6fdda
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 40 deletions.
1 change: 1 addition & 0 deletions MyPersonalConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"PrerequisitePart": {
"AssetPath": "/assets",
"magickinstalllocation": "C:\\PosterTemp\\ImageMagickPortable",
"FollowSymlink": "false",
"maxLogs": "5",
"font": "Colus-Regular.ttf",
"backgroundfont": "Colus-Regular.ttf",
Expand Down
146 changes: 107 additions & 39 deletions Posterizarr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param (
[switch]$SyncEmby
)

$CurrentScriptVersion = "1.9.23"
$CurrentScriptVersion = "1.9.24"
$global:HeaderWritten = $false
$ProgressPreference = 'SilentlyContinue'

Expand Down Expand Up @@ -3528,6 +3528,7 @@ function LogConfigSettings {
Write-Entry -Subtext "Prerequisites Part" -Path $configLogging -Color Cyan -log Info
Write-Entry -Subtext "| Asset Path: $AssetPath" -Path $configLogging -Color White -log Info
Write-Entry -Subtext "| Backup Path: $BackupPath" -Path $configLogging -Color White -log Info
Write-Entry -Subtext "| Follow Symlink: $FollowSymlink" -Path $configLogging -Color White -log Info
Write-Entry -Subtext "| Skip adding Text: $SkipAddText" -Path $configLogging -Color White -log Info
Write-Entry -Subtext "| Manual Asset Path: $ManualAssetPath" -Path $configLogging -Color White -log Info
Write-Entry -Subtext "| Upload to Plex: $Upload2Plex" -Path $configLogging -Color White -log Info
Expand Down Expand Up @@ -4552,18 +4553,35 @@ function MassDownloadPlexArtwork {
$directoryHashtable = @{}
$allowedExtensions = @(".jpg", ".jpeg", ".png", ".bmp")

Get-ChildItem -Path $BackupPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
if ($FollowSymlink){
Get-ChildItem -Path $BackupPath -Recurse -FollowSymlink | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
Else {
$directoryHashtable["$directory\$basename"] = $true
$totalSize += $_.Length
}
}
Else {
Get-ChildItem -Path $BackupPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
$totalSize += $_.Length
}
$totalSize += $_.Length
}

# Convert bytes to kilobytes, megabytes, or gigabytes as needed
Expand Down Expand Up @@ -6293,6 +6311,7 @@ if ($enabledServers -gt 1) {
# Prerequisites Part
$AutoUpdateIM = $config.PrerequisitePart.AutoUpdateIM.tolower()
$show_skipped = $config.PrerequisitePart.show_skipped.tolower()
$FollowSymlink = $config.PrerequisitePart.FollowSymlink.tolower()
$ForceRunningDeletion = $config.PrerequisitePart.ForceRunningDeletion.tolower()
$AssetPath = RemoveTrailingSlash $config.PrerequisitePart.AssetPath
$BackupPath = RemoveTrailingSlash $config.PrerequisitePart.BackupPath
Expand Down Expand Up @@ -8571,18 +8590,35 @@ Elseif ($Tautulli) {
$allowedExtensions = @(".jpg", ".jpeg", ".png", ".bmp")
$totalSize = 0

Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
if ($FollowSymlink){
Get-ChildItem -Path $AssetPath -Recurse -FollowSymlink | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
Else {
$directoryHashtable["$directory\$basename"] = $true
$totalSize += $_.Length
}
}
Else {
Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
$totalSize += $_.Length
}
$totalSize += $_.Length
}

# Convert bytes to kilobytes, megabytes, or gigabytes as needed
Expand Down Expand Up @@ -13501,18 +13537,35 @@ Elseif ($OtherMediaServerUrl -and $OtherMediaServerApiKey -and $UseOtherMediaSer
$directoryHashtable = @{}
$allowedExtensions = @(".jpg", ".jpeg", ".png", ".bmp")

Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
if ($FollowSymlink){
Get-ChildItem -Path $AssetPath -Recurse -FollowSymlink | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
Else {
$directoryHashtable["$directory\$basename"] = $true
$totalSize += $_.Length
}
}
Else {
Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
$totalSize += $_.Length
}
$totalSize += $_.Length
}

# Convert bytes to kilobytes, megabytes, or gigabytes as needed
Expand Down Expand Up @@ -17553,21 +17606,36 @@ else {
try {
$directoryHashtable = @{}
$allowedExtensions = @(".jpg", ".jpeg", ".png", ".bmp")

Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
if ($FollowSymlink){
Get-ChildItem -Path $AssetPath -Recurse -FollowSymlink | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
Else {
$directoryHashtable["$directory\$basename"] = $true
$totalSize += $_.Length
}
}
Else {
Get-ChildItem -Path $AssetPath -Recurse | ForEach-Object {
if ($allowedExtensions -contains $_.Extension.ToLower()) {
$directory = $_.Directory
$basename = $_.BaseName
if ($Platform -eq "Docker" -or $Platform -eq "Linux" -or $Platform -eq 'macOS') {
$directoryHashtable["$directory/$basename"] = $true
}
Else {
$directoryHashtable["$directory\$basename"] = $true
}
}
$totalSize += $_.Length
}
$totalSize += $_.Length
}

# Convert bytes to kilobytes, megabytes, or gigabytes as needed
if ($totalSize -gt 1GB) {
$totalSizeString = "{0:N2} GB" -f ($totalSize / 1GB)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ Posterizarr is cross-platform ready, meaning it can run on Linux (also arm), [Do
- `BackupPath`: Path to store/download Plex posters when using the [backup switch](#backup-mode).
- `ManualAssetPath`: If assets are placed in this directory with the **exact** naming convention (`poster.jpg` & `Season01.jpg`), they will be preferred. (it has to follow the same naming convention as you have in `/assets`)
- `SkipAddText`: If set to `true`, Posterizarr will skip adding text to the poster if it is flagged as a `Poster with text` by the provider.
- `FollowSymlink`: If set to `true`, Posterizarr will follow symbolic links in the specified directories during hashtable creation, allowing it to process files and folders pointed to by the symlinks. This is useful if your assets are organized with symlinks instead of duplicating files.
- `PlexUpload`: If set to `true`, Posterizarr will directly upload the artwork to Plex (handy if you do not use Kometa).
- `ForceRunningDeletion`: If set to `true`, Posterizarr will automatically delete the Running File.
- **Warning:** This may result in multiple concurrent runs sharing the same temporary directory, potentially causing image artifacts or unexpected behavior during processing.
Expand Down
2 changes: 1 addition & 1 deletion Release.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.23
1.9.24
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"PrerequisitePart": {
"AssetPath": "P:\\assets",
"SkipAddText": "false",
"FollowSymlink": "false",
"ForceRunningDeletion": "false",
"AutoUpdatePosterizarr": "false",
"BackupPath": "P:\\assetsbackup",
Expand Down

0 comments on commit ca6fdda

Please sign in to comment.