fix(build): move EstimateBackupSize to platform-independent file
Some checks failed
CI/CD / Test (push) Failing after 4s
CI/CD / Generate SBOM (push) Has been skipped
CI/CD / Lint (push) Failing after 4s
CI/CD / Build (darwin-amd64) (push) Has been skipped
CI/CD / Build (linux-amd64) (push) Has been skipped
CI/CD / Build (darwin-arm64) (push) Has been skipped
CI/CD / Build (linux-arm64) (push) Has been skipped
CI/CD / Release (push) Has been skipped
CI/CD / Build & Push Docker Image (push) Has been skipped
CI/CD / Mirror to GitHub (push) Has been skipped
Some checks failed
CI/CD / Test (push) Failing after 4s
CI/CD / Generate SBOM (push) Has been skipped
CI/CD / Lint (push) Failing after 4s
CI/CD / Build (darwin-amd64) (push) Has been skipped
CI/CD / Build (linux-amd64) (push) Has been skipped
CI/CD / Build (darwin-arm64) (push) Has been skipped
CI/CD / Build (linux-arm64) (push) Has been skipped
CI/CD / Release (push) Has been skipped
CI/CD / Build & Push Docker Image (push) Has been skipped
CI/CD / Mirror to GitHub (push) Has been skipped
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:
@@ -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)
|
|
||||||
}
|
|
||||||
|
|||||||
26
internal/checks/estimate.go
Normal file
26
internal/checks/estimate.go
Normal 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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user