updated create,restore commands for backup directory and added utils.go

file
This commit is contained in:
wt committed 2025-08-02 16:58:12 +07:00
1 parent 7df9eeb8eb
commit 3bef3f76e9
4 files changed
+125 -49

No files matched your search

+2 -15
View File
@@ -162,7 +162,7 @@ func (m *model) startBackup() tea.Msg {
m.progressCh <- -2
return
}
m.target += ".gz"
// Обработка файлов и дисков
srcFile, err := os.Open(m.source)
if err != nil {
@@ -171,7 +171,7 @@ func (m *model) startBackup() tea.Msg {
}
defer srcFile.Close()
dstFile, err := os.Create(m.target + ".gz")
dstFile, err := os.Create(m.target)
if err != nil {
m.progressCh <- -1
return
@@ -377,19 +377,6 @@ func (m *model) View() string {
)
}
func formatBytes(b int64) string {
const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := int64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp])
}
func init() {
rootCmd.AddCommand(createCmd)
createCmd.Flags().StringVarP(&source, "source", "s", "", "Source file, directory or disk (e.g., /dev/sda) (required)")