CRITICAL FIX: Eliminate all hardcoded /tmp paths - respect WorkDir configuration
This is a critical bugfix release addressing multiple hardcoded temporary directory paths that prevented proper use of the WorkDir configuration option. PROBLEM: Users configuring WorkDir (e.g., /u01/dba/tmp) for systems with small root filesystems still experienced failures because critical operations hardcoded /tmp instead of respecting the configured WorkDir. This made the WorkDir option essentially non-functional. FIXED LOCATIONS: 1. internal/restore/engine.go:632 - CRITICAL: Used BackupDir instead of WorkDir for extraction 2. cmd/restore.go:354,834 - CLI restore/diagnose commands ignored WorkDir 3. cmd/migrate.go:208,347 - Migration commands hardcoded /tmp 4. internal/migrate/engine.go:120 - Migration engine ignored WorkDir 5. internal/config/config.go:224 - SwapFilePath hardcoded /tmp 6. internal/config/config.go:519 - Backup directory fallback hardcoded /tmp 7. internal/tui/restore_exec.go:161 - Debug logs hardcoded /tmp 8. internal/tui/settings.go:805 - Directory browser default hardcoded /tmp 9. internal/tui/restore_preview.go:474 - Display message hardcoded /tmp NEW FEATURES: - Added Config.GetEffectiveWorkDir() helper method - WorkDir now respects WORK_DIR environment variable - All temp operations now consistently use configured WorkDir with /tmp fallback IMPACT: - Restores on systems with small root disks now work properly with WorkDir configured - Admins can control disk space usage for all temporary operations - Debug logs, extraction dirs, swap files all respect WorkDir setting Version: 3.42.1 (Critical Fix Release)
This commit is contained in:
@@ -47,9 +47,10 @@ type DownloadResult struct {
|
||||
|
||||
// Download downloads a backup from cloud storage
|
||||
func (d *CloudDownloader) Download(ctx context.Context, remotePath string, opts DownloadOptions) (*DownloadResult, error) {
|
||||
// Determine temp directory
|
||||
// Determine temp directory (use from opts, or from config's WorkDir, or fallback to system temp)
|
||||
tempDir := opts.TempDir
|
||||
if tempDir == "" {
|
||||
// Try to get from config if available (passed via opts.TempDir)
|
||||
tempDir = os.TempDir()
|
||||
}
|
||||
|
||||
|
||||
@@ -628,11 +628,12 @@ func (e *Engine) RestoreCluster(ctx context.Context, archivePath string) error {
|
||||
|
||||
e.progress.Start(fmt.Sprintf("Restoring cluster from %s", filepath.Base(archivePath)))
|
||||
|
||||
// Create temporary extraction directory
|
||||
tempDir := filepath.Join(e.cfg.BackupDir, fmt.Sprintf(".restore_%d", time.Now().Unix()))
|
||||
// Create temporary extraction directory in configured WorkDir
|
||||
workDir := e.cfg.GetEffectiveWorkDir()
|
||||
tempDir := filepath.Join(workDir, fmt.Sprintf(".restore_%d", time.Now().Unix()))
|
||||
if err := os.MkdirAll(tempDir, 0755); err != nil {
|
||||
operation.Fail("Failed to create temporary directory")
|
||||
return fmt.Errorf("failed to create temp directory: %w", err)
|
||||
return fmt.Errorf("failed to create temp directory in %s: %w", workDir, err)
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user