diff --git a/build/gdrive_retention.ps1 b/build/gdrive_retention.ps1 index 37cafff..29de8d3 100644 --- a/build/gdrive_retention.ps1 +++ b/build/gdrive_retention.ps1 @@ -1,9 +1,6 @@ -param ( - [string]$Path = "." -) - # Configuration $rcloneRemote = "AzaionGoogleDrive:AzaionSuiteBuilds" +$rclone = "rclone" # Assuming rclone is available in the PATH. function Write-Header($text) { Write-Host "`n=== $text ===`n" -ForegroundColor Cyan @@ -24,8 +21,16 @@ function Write-ErrorMsg($text) { Write-Header "Starting cleanup of older Full and Iterative installers on Google Drive" Write-Info "Listing all files in: $rcloneRemote" -$allFilesRaw = rclone lsf --files-only $rcloneRemote +$allFilesRaw = & $rclone lsf --files-only $rcloneRemote + +# Check if the command succeeded +if ($LASTEXITCODE -ne 0) { + Write-ErrorMsg "Failed to list files from Google Drive using rclone." + exit 1 +} + $allFiles = $allFilesRaw -split "`n" | Where-Object { $_ -ne "" } + if ($allFiles.Count -eq 0) { Write-WarningMsg "No files found in the remote folder." exit 0 @@ -57,7 +62,7 @@ if ($fullFiles.Count -eq 0) { } foreach ($file in $fullToDelete) { - $res = rclone deletefile "$rcloneRemote/$file" 2>&1 + $res = & $rclone deletefile "$rcloneRemote/$file" 2>&1 if ($LASTEXITCODE -eq 0) { Write-Info "Deleted Full installer: $file" } else { @@ -89,7 +94,7 @@ if ($iterativeFiles.Count -eq 0) { } foreach ($file in $iterativeToDelete) { - $res = rclone deletefile "$rcloneRemote/$file" 2>&1 + $res = & $rclone deletefile "$rcloneRemote/$file" 2>&1 if ($LASTEXITCODE -eq 0) { Write-Info "Deleted Iterative installer: $file" } else {