From 481814ed2c4245a01360e8b23853346b1eed2087 Mon Sep 17 00:00:00 2001 From: danrahn Date: Sat, 24 May 2025 10:34:41 -0700 Subject: [PATCH 1/2] Add statistics_bandwidth cleanup to Windows scripts --- Windows/DBRepair-Windows.bat | 4 ++++ Windows/DBRepair-Windows.ps1 | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Windows/DBRepair-Windows.bat b/Windows/DBRepair-Windows.bat index 749e793..78e9345 100644 --- a/Windows/DBRepair-Windows.bat +++ b/Windows/DBRepair-Windows.bat @@ -94,6 +94,10 @@ cd "%PlexData%" md "%PlexData%\dbtmp" 2>NUL del "%TmpFile%" 2>NUL +echo %time% -- Performing DB cleanup tasks +echo %time% -- Performing DB cleanup tasks >> "%PlexData%\DBRepair.log" +"%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db" "DELETE FROM statistics_bandwidth WHERE account_id IS NULL;" + echo %time% -- Exporting Main DB echo %time% -- Exporting Main DB >> "%PlexData%\DBRepair.log" echo .dump | "%PlexSQL%" "%PlexData%\com.plexapp.plugins.library.db" > "%DBtmp%\library.sql_%TimeStamp%" diff --git a/Windows/DBRepair-Windows.ps1 b/Windows/DBRepair-Windows.ps1 index 85a447c..d9e1435 100644 --- a/Windows/DBRepair-Windows.ps1 +++ b/Windows/DBRepair-Windows.ps1 @@ -326,9 +326,17 @@ class DBRepair { } } - $this.Output("Exporting Main DB") $MainDBName = "com.plexapp.plugins.library.db" $MainDB = Join-Path $this.PlexDBDir -ChildPath $MainDBName + + # Temporary DB actions + $this.WriteOutputLog("Performing DB cleanup tasks.") + $ignoreErrorsSaved = $this.Options.IgnoreErrors # This isn't a critical task, allow it to fail without stopping the script + $this.Options.IgnoreErrors = $true + $this.RunSqlCommand("""$MainDB"" ""DELETE from statistics_bandwidth WHERE account_id IS NULL;""", "Failed to clean up statistics_bandwidth table.") + $this.Options.IgnoreErrors = $ignoreErrorsSaved + + $this.Output("Exporting Main DB") $MainDBSQL = Join-Path $DBTemp -ChildPath "library.sql_$($this.TimeStamp)" if (!$this.FileExists($MainDB)) { $this.ExitDBMaintenance("Could not find $MainDBName in database directory", $false) @@ -786,7 +794,7 @@ class DBRepair { } } - $this.Options.CanIgnore = $false + $this.Options.CanIgnore = $true return $result } From 3bb22f56cd68140052865c8cb73f1a4eac4dfe1e Mon Sep 17 00:00:00 2001 From: danrahn Date: Sat, 24 May 2025 14:34:44 -0700 Subject: [PATCH 2/2] Bump version --- Windows/DBRepair-Windows.ps1 | 2 +- Windows/ReleaseNotes-Windows | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Windows/DBRepair-Windows.ps1 b/Windows/DBRepair-Windows.ps1 index d9e1435..41adee2 100644 --- a/Windows/DBRepair-Windows.ps1 +++ b/Windows/DBRepair-Windows.ps1 @@ -3,7 +3,7 @@ # # ######################################################################### -$DBRepairVersion = 'v1.01.00' +$DBRepairVersion = 'v1.01.01' class DBRepair { [DBRepairOptions] $Options diff --git a/Windows/ReleaseNotes-Windows b/Windows/ReleaseNotes-Windows index e46e09a..5be1497 100644 --- a/Windows/ReleaseNotes-Windows +++ b/Windows/ReleaseNotes-Windows @@ -4,6 +4,9 @@ Release notes for the Windows counterpart to DBRepair.sh (DBRepair-Windows.ps1) # Release Info +v1.01.01 + - Add `staticstics_bandwidth` pruning during automatic repair. + v1.01.00 - Rename this tool to be compliant with Plex inc. Trademark Policy.