fix(build): move EstimateBackupSize to platform-independent file

Fixes Windows, OpenBSD, and NetBSD builds by extracting
EstimateBackupSize from disk_check.go (which has build tags
excluding those platforms) to a new estimate.go file.
This commit is contained in:
2025-12-13 21:55:39 +01:00
parent 573f2776d7
commit 0fb811579d
10 changed files with 126 additions and 125 deletions

View File

@@ -109,28 +109,3 @@ func FormatDiskSpaceMessage(check *DiskSpaceCheck) string {
return msg return msg
} }
// EstimateBackupSize estimates backup size based on database size
func EstimateBackupSize(databaseSize uint64, compressionLevel int) uint64 {
// Typical compression ratios:
// Level 0 (no compression): 1.0x
// Level 1-3 (fast): 0.4-0.6x
// Level 4-6 (balanced): 0.3-0.4x
// Level 7-9 (best): 0.2-0.3x
var compressionRatio float64
if compressionLevel == 0 {
compressionRatio = 1.0
} else if compressionLevel <= 3 {
compressionRatio = 0.5
} else if compressionLevel <= 6 {
compressionRatio = 0.35
} else {
compressionRatio = 0.25
}
estimated := uint64(float64(databaseSize) * compressionRatio)
// Add 10% buffer for metadata, indexes, etc.
return uint64(float64(estimated) * 1.1)
}

View File

@@ -0,0 +1,26 @@
package checks
// EstimateBackupSize estimates backup size based on database size
func EstimateBackupSize(databaseSize uint64, compressionLevel int) uint64 {
// Typical compression ratios:
// Level 0 (no compression): 1.0x
// Level 1-3 (fast): 0.4-0.6x
// Level 4-6 (balanced): 0.3-0.4x
// Level 7-9 (best): 0.2-0.3x
var compressionRatio float64
if compressionLevel == 0 {
compressionRatio = 1.0
} else if compressionLevel <= 3 {
compressionRatio = 0.5
} else if compressionLevel <= 6 {
compressionRatio = 0.35
} else {
compressionRatio = 0.25
}
estimated := uint64(float64(databaseSize) * compressionRatio)
// Add 10% buffer for metadata, indexes, etc.
return uint64(float64(estimated) * 1.1)
}