From 15a60d2e717841403176f6dfb65d10004b1c27dd Mon Sep 17 00:00:00 2001 From: Alexander Renz Date: Thu, 8 Jan 2026 06:05:25 +0100 Subject: [PATCH] v3.42.10: Code quality fixes - Remove deprecated io/ioutil - Fix os.DirEntry.ModTime() usage - Remove unused fields and variables - Fix ineffective assignments - Fix error string formatting --- CHANGELOG.md | 9 +++++++++ bin/README.md | 4 ++-- internal/cloud/azure.go | 2 +- internal/database/postgresql.go | 1 - internal/engine/snapshot/btrfs.go | 2 +- internal/restore/engine.go | 7 +++---- internal/tui/confirmation.go | 2 -- internal/tui/history.go | 12 +++++++++--- internal/tui/settings.go | 1 - main.go | 2 +- 10 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 697a3db..c6b9c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to dbbackup will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.42.10] - 2026-01-08 "Code Quality" + +### Fixed - Code Quality Issues +- Removed deprecated `io/ioutil` usage (replaced with `os`) +- Fixed `os.DirEntry.ModTime()` → `file.Info().ModTime()` +- Removed unused fields and variables +- Fixed ineffective assignments in TUI code +- Fixed error strings (no capitalization, no trailing punctuation) + ## [3.42.9] - 2026-01-08 "Diagnose Timeout Fix" ### Fixed - diagnose.go Timeout Bugs diff --git a/bin/README.md b/bin/README.md index 147d442..7a715be 100644 --- a/bin/README.md +++ b/bin/README.md @@ -4,8 +4,8 @@ This directory contains pre-compiled binaries for the DB Backup Tool across mult ## Build Information - **Version**: 3.42.1 -- **Build Time**: 2026-01-08_04:54:46_UTC -- **Git Commit**: 627061c +- **Build Time**: 2026-01-08_05:03:53_UTC +- **Git Commit**: 9c65821 ## Recent Updates (v1.1.0) - ✅ Fixed TUI progress display with line-by-line output diff --git a/internal/cloud/azure.go b/internal/cloud/azure.go index 25cc04a..25706cf 100644 --- a/internal/cloud/azure.go +++ b/internal/cloud/azure.go @@ -90,7 +90,7 @@ func NewAzureBackend(cfg *Config) (*AzureBackend, error) { } } else { // Use default Azure credential (managed identity, environment variables, etc.) - return nil, fmt.Errorf("Azure authentication requires account name and key, or use AZURE_STORAGE_CONNECTION_STRING environment variable") + return nil, fmt.Errorf("azure authentication requires account name and key, or use AZURE_STORAGE_CONNECTION_STRING environment variable") } } diff --git a/internal/database/postgresql.go b/internal/database/postgresql.go index 921b5c1..f826e5a 100755 --- a/internal/database/postgresql.go +++ b/internal/database/postgresql.go @@ -15,7 +15,6 @@ import ( "github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/stdlib" - _ "github.com/jackc/pgx/v5/stdlib" // PostgreSQL driver (pgx) ) // PostgreSQL implements Database interface for PostgreSQL diff --git a/internal/engine/snapshot/btrfs.go b/internal/engine/snapshot/btrfs.go index e0fc2de..bf1c1f9 100644 --- a/internal/engine/snapshot/btrfs.go +++ b/internal/engine/snapshot/btrfs.go @@ -63,7 +63,7 @@ func (b *BtrfsBackend) Detect(dataDir string) (bool, error) { // CreateSnapshot creates a Btrfs snapshot func (b *BtrfsBackend) CreateSnapshot(ctx context.Context, opts SnapshotOptions) (*Snapshot, error) { if b.config == nil || b.config.Subvolume == "" { - return nil, fmt.Errorf("Btrfs subvolume not configured") + return nil, fmt.Errorf("btrfs subvolume not configured") } // Generate snapshot name diff --git a/internal/restore/engine.go b/internal/restore/engine.go index a24f872..f6f7e1e 100755 --- a/internal/restore/engine.go +++ b/internal/restore/engine.go @@ -27,8 +27,7 @@ type Engine struct { progress progress.Indicator detailedReporter *progress.DetailedReporter dryRun bool - debugLogPath string // Path to save debug log on error - errorCollector *ErrorCollector // Collects detailed error info + debugLogPath string // Path to save debug log on error } // New creates a new restore engine @@ -803,8 +802,8 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error { if len(corruptedDumps) > 0 { operation.Fail("Corrupted dump files detected") e.progress.Fail(fmt.Sprintf("Found %d corrupted dump files - restore aborted", len(corruptedDumps))) - return fmt.Errorf("pre-validation failed: %d corrupted dump files detected:\n %s\n\nThe backup archive appears to be damaged. You need to restore from a different backup.", - len(corruptedDumps), strings.Join(corruptedDumps, "\n ")) + return fmt.Errorf("pre-validation failed: %d corrupted dump files detected: %s - the backup archive appears to be damaged, restore from a different backup", + len(corruptedDumps), strings.Join(corruptedDumps, ", ")) } e.log.Info("All dump files passed validation") diff --git a/internal/tui/confirmation.go b/internal/tui/confirmation.go index 4dad945..4a91dd7 100755 --- a/internal/tui/confirmation.go +++ b/internal/tui/confirmation.go @@ -67,7 +67,6 @@ func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case autoConfirmMsg: // Auto-confirm triggered - m.confirmed = true if m.onConfirm != nil { return m.onConfirm() } @@ -95,7 +94,6 @@ func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "enter", "y": if msg.String() == "y" || m.cursor == 0 { - m.confirmed = true // Execute the onConfirm callback if provided if m.onConfirm != nil { return m.onConfirm() diff --git a/internal/tui/history.go b/internal/tui/history.go index 84d0443..2af2e17 100755 --- a/internal/tui/history.go +++ b/internal/tui/history.go @@ -2,7 +2,7 @@ package tui import ( "fmt" - "io/ioutil" + "os" "strings" "time" @@ -59,7 +59,7 @@ func loadHistory(cfg *config.Config) []HistoryEntry { var entries []HistoryEntry // Read backup files from backup directory - files, err := ioutil.ReadDir(cfg.BackupDir) + files, err := os.ReadDir(cfg.BackupDir) if err != nil { return entries } @@ -74,6 +74,12 @@ func loadHistory(cfg *config.Config) []HistoryEntry { continue } + // Get file info for ModTime + info, err := file.Info() + if err != nil { + continue + } + var backupType string var database string @@ -97,7 +103,7 @@ func loadHistory(cfg *config.Config) []HistoryEntry { entries = append(entries, HistoryEntry{ Type: backupType, Database: database, - Timestamp: file.ModTime(), + Timestamp: info.ModTime(), Status: "✅ Completed", Filename: name, }) diff --git a/internal/tui/settings.go b/internal/tui/settings.go index 9ebfa03..0a32023 100755 --- a/internal/tui/settings.go +++ b/internal/tui/settings.go @@ -482,7 +482,6 @@ func (m SettingsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg.String() { case "ctrl+c", "q", "esc": - m.quitting = true return m.parent, nil case "up", "k": diff --git a/main.go b/main.go index 26ba8b8..24dc2ca 100755 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( // Build information (set by ldflags) var ( - version = "3.42.9" + version = "3.42.10" buildTime = "unknown" gitCommit = "unknown" )