feat(tui): add Work Directory setting for large archive operations
- Added WorkDir to Config for custom temp directory - TUI Settings: new 'Work Directory' option to set alternative temp location - Restore Preview: press 'w' to toggle work directory (uses backup dir as default) - Diagnose View: now uses configured WorkDir for cluster extraction - Config persistence: WorkDir saved to .dbbackup.conf This fixes diagnosis/restore failures when /tmp is too small for large archives. Use cases: servers with limited /tmp, 70GB+ archives needing 280GB+ extraction space.
This commit is contained in:
@@ -88,8 +88,8 @@ func runDiagnosis(cfg *config.Config, log logger.Logger, archive ArchiveInfo) te
|
||||
|
||||
// For cluster archives, we can do deep analysis
|
||||
if archive.Format.IsClusterBackup() {
|
||||
// Create temp directory
|
||||
tempDir, err := createTempDir("dbbackup-diagnose-*")
|
||||
// Create temp directory (use WorkDir if configured for large archives)
|
||||
tempDir, err := createTempDirIn(cfg.WorkDir, "dbbackup-diagnose-*")
|
||||
if err != nil {
|
||||
return diagnoseCompleteMsg{err: fmt.Errorf("failed to create temp dir: %w", err)}
|
||||
}
|
||||
@@ -445,6 +445,17 @@ func createTempDir(pattern string) (string, error) {
|
||||
return os.MkdirTemp("", pattern)
|
||||
}
|
||||
|
||||
func createTempDirIn(baseDir, pattern string) (string, error) {
|
||||
if baseDir == "" {
|
||||
return os.MkdirTemp("", pattern)
|
||||
}
|
||||
// Ensure base directory exists
|
||||
if err := os.MkdirAll(baseDir, 0755); err != nil {
|
||||
return "", fmt.Errorf("cannot create work directory: %w", err)
|
||||
}
|
||||
return os.MkdirTemp(baseDir, pattern)
|
||||
}
|
||||
|
||||
func removeTempDir(path string) error {
|
||||
return os.RemoveAll(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user