Merge pull request #202 from danrahn/master

Add statistics_bandwidth Cleanup to Windows Scripts
This commit is contained in:
Chuck 2025-05-24 19:17:45 -04:00 committed by GitHub
commit 8c5f7606a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View File

@ -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%"

View File

@ -3,7 +3,7 @@
# #
#########################################################################
$DBRepairVersion = 'v1.01.00'
$DBRepairVersion = 'v1.01.01'
class DBRepair {
[DBRepairOptions] $Options
@ -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
}

View File

@ -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.