Fix cross-platform compilation for all target platforms
- Fixed type mismatch in disk space calculation (int64 casting) - Created platform-specific disk space implementations: * diskspace_unix.go (Linux, macOS, FreeBSD) * diskspace_windows.go (Windows) * diskspace_bsd.go (OpenBSD) * diskspace_netbsd.go (NetBSD fallback) - All 10 platforms now compile successfully: ✅ Linux (amd64, arm64, armv7) ✅ macOS (Intel, Apple Silicon) ✅ Windows (amd64, arm64) ✅ FreeBSD, OpenBSD, NetBSD
This commit is contained in:
@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"dbbackup/internal/config"
|
||||
"dbbackup/internal/logger"
|
||||
@ -243,14 +242,12 @@ func (s *Safety) CheckDiskSpace(archivePath string, multiplier float64) error {
|
||||
requiredSpace := int64(float64(archiveSize) * multiplier)
|
||||
|
||||
// Get available disk space
|
||||
var statfs syscall.Statfs_t
|
||||
if err := syscall.Statfs(s.cfg.BackupDir, &statfs); err != nil {
|
||||
availableSpace, err := getDiskSpace(s.cfg.BackupDir)
|
||||
if err != nil {
|
||||
s.log.Warn("Cannot check disk space", "error", err)
|
||||
return nil // Don't fail if we can't check
|
||||
}
|
||||
|
||||
availableSpace := int64(statfs.Bavail) * statfs.Bsize
|
||||
|
||||
if availableSpace < requiredSpace {
|
||||
return fmt.Errorf("insufficient disk space: need %s, have %s",
|
||||
FormatBytes(requiredSpace), FormatBytes(availableSpace))
|
||||
|
||||
Reference in New Issue
Block a user