Show sync counts and progress bars

This commit is contained in:
DESKTOP-KSVGT20\shkim
2026-05-02 01:48:35 +09:00
parent 8efd24a50a
commit c79d11aa47
2 changed files with 103 additions and 10 deletions
+31 -3
View File
@@ -251,6 +251,21 @@ function Get-QueueSnapshot {
}
}
function Format-ProgressBar {
param(
[int]$Done,
[int]$Total,
[int]$Width = 28
)
if ($Total -le 0) {
return "[" + ("-" * $Width) + "]"
}
$ratio = [Math]::Max(0, [Math]::Min(1, $Done / $Total))
$filled = [int][Math]::Round($ratio * $Width)
return "[" + ("#" * $filled) + ("-" * ($Width - $filled)) + "]"
}
function Stop-AllWork {
$stopped = 0
foreach ($job in @($script:activeJobs)) {
@@ -288,6 +303,7 @@ function Show-Dashboard {
Write-Host "Logs: $logs"
Write-Host ""
Write-Host ("Workers: {0}/{1} Queue: {2} Done: {3}/{4} Failed: {5} Progress: {6}%" -f $snapshot.activeCount, $snapshot.maxWorkers, $snapshot.queued, $snapshot.done, $snapshot.total, $snapshot.failed, $snapshot.percent)
Write-Host ("{0} {1}/{2}" -f (Format-ProgressBar $snapshot.done $snapshot.total), $snapshot.done, $snapshot.total) -ForegroundColor Cyan
Write-Host ""
if ($snapshot.activeJobs.Count) {
@@ -381,7 +397,8 @@ function Add-TracksToQueue {
[void]$queueIds.Add($id)
$added += $track
}
$script:stats.total += @($added).Count
$script:stats.total += (@($added).Count + $skipped)
$script:stats.completed += $skipped
$script:stats.skipped += $skipped
Update-Queue
$snapshot = Get-QueueSnapshot
@@ -446,17 +463,23 @@ function Get-MissingTracks {
$existingIds = Get-ExistingSunoIds $libraryRoot
$missing = @()
$existingRequested = @()
$invalid = 0
foreach ($track in @($Tracks)) {
$id = "$($track.id)".Trim()
if (-not $id) { continue }
if (-not $id) { $invalid++; continue }
if (-not $existingIds.Contains($id)) {
$missing += $track
} else {
$existingRequested += $track
}
}
return [pscustomobject]@{
existingIds = @($existingIds)
existingRequested = $existingRequested
missing = $missing
invalid = $invalid
}
}
@@ -545,8 +568,13 @@ try {
outputRoot = $OutputRoot
libraryRoot = $libraryRoot
artist = $ArtistName
requested = @($manifest.tracks).Count
received = @($manifest.tracks).Count
existing = @($result.existingIds).Count
libraryExistingTotal = @($result.existingIds).Count
existingRequested = @($result.existingRequested).Count
missingRequested = @($result.missing).Count
invalidRequested = $result.invalid
existing = @($result.existingRequested).Count
missing = @($result.missing).Count
tracks = @($result.missing)
} | ConvertTo-Json -Depth 50 -Compress)