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
This commit is contained in:
2026-01-08 06:05:25 +01:00
parent 9c65821250
commit 5b51ed22b1
10 changed files with 26 additions and 16 deletions

View File

@@ -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/), 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). 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" ## [3.42.9] - 2026-01-08 "Diagnose Timeout Fix"
### Fixed - diagnose.go Timeout Bugs ### Fixed - diagnose.go Timeout Bugs

View File

@@ -4,8 +4,8 @@ This directory contains pre-compiled binaries for the DB Backup Tool across mult
## Build Information ## Build Information
- **Version**: 3.42.1 - **Version**: 3.42.1
- **Build Time**: 2026-01-08_04:54:46_UTC - **Build Time**: 2026-01-08_05:03:53_UTC
- **Git Commit**: 627061c - **Git Commit**: 9c65821
## Recent Updates (v1.1.0) ## Recent Updates (v1.1.0)
- ✅ Fixed TUI progress display with line-by-line output - ✅ Fixed TUI progress display with line-by-line output

View File

@@ -90,7 +90,7 @@ func NewAzureBackend(cfg *Config) (*AzureBackend, error) {
} }
} else { } else {
// Use default Azure credential (managed identity, environment variables, etc.) // 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")
} }
} }

View File

@@ -15,7 +15,6 @@ import (
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
"github.com/jackc/pgx/v5/stdlib" "github.com/jackc/pgx/v5/stdlib"
_ "github.com/jackc/pgx/v5/stdlib" // PostgreSQL driver (pgx)
) )
// PostgreSQL implements Database interface for PostgreSQL // PostgreSQL implements Database interface for PostgreSQL

View File

@@ -63,7 +63,7 @@ func (b *BtrfsBackend) Detect(dataDir string) (bool, error) {
// CreateSnapshot creates a Btrfs snapshot // CreateSnapshot creates a Btrfs snapshot
func (b *BtrfsBackend) CreateSnapshot(ctx context.Context, opts SnapshotOptions) (*Snapshot, error) { func (b *BtrfsBackend) CreateSnapshot(ctx context.Context, opts SnapshotOptions) (*Snapshot, error) {
if b.config == nil || b.config.Subvolume == "" { 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 // Generate snapshot name

View File

@@ -28,7 +28,6 @@ type Engine struct {
detailedReporter *progress.DetailedReporter detailedReporter *progress.DetailedReporter
dryRun bool dryRun bool
debugLogPath string // Path to save debug log on error debugLogPath string // Path to save debug log on error
errorCollector *ErrorCollector // Collects detailed error info
} }
// New creates a new restore engine // New creates a new restore engine
@@ -803,8 +802,8 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error {
if len(corruptedDumps) > 0 { if len(corruptedDumps) > 0 {
operation.Fail("Corrupted dump files detected") operation.Fail("Corrupted dump files detected")
e.progress.Fail(fmt.Sprintf("Found %d corrupted dump files - restore aborted", len(corruptedDumps))) 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.", 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, "\n ")) len(corruptedDumps), strings.Join(corruptedDumps, ", "))
} }
e.log.Info("All dump files passed validation") e.log.Info("All dump files passed validation")

View File

@@ -67,7 +67,6 @@ func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) { switch msg := msg.(type) {
case autoConfirmMsg: case autoConfirmMsg:
// Auto-confirm triggered // Auto-confirm triggered
m.confirmed = true
if m.onConfirm != nil { if m.onConfirm != nil {
return m.onConfirm() return m.onConfirm()
} }
@@ -95,7 +94,6 @@ func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "enter", "y": case "enter", "y":
if msg.String() == "y" || m.cursor == 0 { if msg.String() == "y" || m.cursor == 0 {
m.confirmed = true
// Execute the onConfirm callback if provided // Execute the onConfirm callback if provided
if m.onConfirm != nil { if m.onConfirm != nil {
return m.onConfirm() return m.onConfirm()

View File

@@ -2,7 +2,7 @@ package tui
import ( import (
"fmt" "fmt"
"io/ioutil" "os"
"strings" "strings"
"time" "time"
@@ -59,7 +59,7 @@ func loadHistory(cfg *config.Config) []HistoryEntry {
var entries []HistoryEntry var entries []HistoryEntry
// Read backup files from backup directory // Read backup files from backup directory
files, err := ioutil.ReadDir(cfg.BackupDir) files, err := os.ReadDir(cfg.BackupDir)
if err != nil { if err != nil {
return entries return entries
} }
@@ -74,6 +74,12 @@ func loadHistory(cfg *config.Config) []HistoryEntry {
continue continue
} }
// Get file info for ModTime
info, err := file.Info()
if err != nil {
continue
}
var backupType string var backupType string
var database string var database string
@@ -97,7 +103,7 @@ func loadHistory(cfg *config.Config) []HistoryEntry {
entries = append(entries, HistoryEntry{ entries = append(entries, HistoryEntry{
Type: backupType, Type: backupType,
Database: database, Database: database,
Timestamp: file.ModTime(), Timestamp: info.ModTime(),
Status: "✅ Completed", Status: "✅ Completed",
Filename: name, Filename: name,
}) })

View File

@@ -482,7 +482,6 @@ func (m SettingsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.String() { switch msg.String() {
case "ctrl+c", "q", "esc": case "ctrl+c", "q", "esc":
m.quitting = true
return m.parent, nil return m.parent, nil
case "up", "k": case "up", "k":

View File

@@ -16,7 +16,7 @@ import (
// Build information (set by ldflags) // Build information (set by ldflags)
var ( var (
version = "3.42.9" version = "3.42.10"
buildTime = "unknown" buildTime = "unknown"
gitCommit = "unknown" gitCommit = "unknown"
) )