Skip to content

Commit b89dd70

Browse files
refactor: consolidate Dotfile type definition in output package
- Remove duplicate Dotfle and BackupMetadata structs from backup package - Use output.Dotfile as single source of truth for backup data structures - Fix type incompatibility error in CreateDotfileBckup function
1 parent 1ac682e commit b89dd70

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

go.mod

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
module github.com/mdgspace/sysreplicate
2-
3-
go 1.24.3
4-
5-
require golang.org/x/term v0.32.0
6-
7-
require golang.org/x/sys v0.33.0 // indirect
1+
module github.com/mdgspace/sysreplicate
2+
3+
go 1.24.3

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
2-
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
3-
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
4-
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=

system/backup/dotfiles_backup.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,31 @@ func (db *DotfileBackupManager) CreateDotfileBackup(outputTar string) error {
2828

2929
hostname, _ := os.Hostname()
3030

31+
// Convert []Dotfile to []output.Dotfile
32+
outputFiles := make([]output.Dotfile, len(files))
33+
for i, file := range files {
34+
outputFiles[i] = output.Dotfile{
35+
Path: file.Path,
36+
RealPath: file.RealPath,
37+
IsDir: file.IsDir,
38+
IsBinary: file.IsBinary,
39+
Mode: file.Mode,
40+
Content: file.Content,
41+
}
42+
}
43+
44+
3145
// Create backup metadata
32-
meta := &BackupMetadata{
46+
// struct from output
47+
meta := &output.BackupMetadata{
3348
Timestamp: time.Now(),
3449
Hostname: hostname,
35-
Files: files,
50+
Files: outputFiles,
3651
}
3752

38-
// Tarball creation
39-
if err := CreateDotfilesBackupTarball(meta, outputTar); err != nil {
40-
return fmt.Errorf("failed to create backup tarball: %w", err)
41-
}
53+
if err := output.CreateDotfilesBackupTarball(meta, outputTar); err != nil {
54+
return fmt.Errorf("failed to create backup tarball: %w", err)
55+
}
4256

4357
fmt.Println("Backup complete:", outputTar)
4458
return nil

0 commit comments

Comments
 (0)