mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 23:18:49 +00:00
fix: improve disk space check logic in ResourceChecker
- Updated CheckDiskSpace method to validate disk space against the parent directory if the specified path does not exist. - Enhanced error handling to ensure accurate reporting of disk space validation failures.
This commit is contained in:
parent
b1732b2cbe
commit
b896e37e09
14
CHANGELOG.md
14
CHANGELOG.md
@ -13,6 +13,20 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
|||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
## [0.67.1] - 2025-11-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
\n
|
||||||
|
### Changed
|
||||||
|
- Improved disk space check logic to correctly check the parent directory if the specified path does not exist.
|
||||||
|
|
||||||
|
### Deprecated
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed an issue in the installation script where the extracted CLI binary might be named 'dbn' instead of 'network-cli', ensuring successful installation regardless of the extracted filename.
|
||||||
|
|
||||||
## [0.67.0] - 2025-11-11
|
## [0.67.0] - 2025-11-11
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -19,7 +19,7 @@ test-e2e:
|
|||||||
|
|
||||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
|
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill
|
||||||
|
|
||||||
VERSION := 0.67.0
|
VERSION := 0.67.1
|
||||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -226,8 +227,18 @@ func NewResourceChecker() *ResourceChecker {
|
|||||||
|
|
||||||
// CheckDiskSpace validates sufficient disk space (minimum 10GB free)
|
// CheckDiskSpace validates sufficient disk space (minimum 10GB free)
|
||||||
func (rc *ResourceChecker) CheckDiskSpace(path string) error {
|
func (rc *ResourceChecker) CheckDiskSpace(path string) error {
|
||||||
|
checkPath := path
|
||||||
|
|
||||||
|
// If the path doesn't exist, check the parent directory instead
|
||||||
|
for checkPath != "/" {
|
||||||
|
if _, err := os.Stat(checkPath); err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
checkPath = filepath.Dir(checkPath)
|
||||||
|
}
|
||||||
|
|
||||||
var stat syscall.Statfs_t
|
var stat syscall.Statfs_t
|
||||||
if err := syscall.Statfs(path, &stat); err != nil {
|
if err := syscall.Statfs(checkPath, &stat); err != nil {
|
||||||
return fmt.Errorf("failed to check disk space: %w", err)
|
return fmt.Errorf("failed to check disk space: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,18 +144,23 @@ download_and_install_cli() {
|
|||||||
# Extract to /tmp
|
# Extract to /tmp
|
||||||
tar -xzf /tmp/dbn.tar.gz -C /tmp/
|
tar -xzf /tmp/dbn.tar.gz -C /tmp/
|
||||||
|
|
||||||
# Check if binary exists after extraction (it's named network-cli in the archive)
|
# Check for extracted binary (could be named network-cli or dbn)
|
||||||
if [ ! -f /tmp/network-cli ]; then
|
EXTRACTED_BINARY=""
|
||||||
error "Failed to extract network-cli binary"
|
if [ -f /tmp/network-cli ]; then
|
||||||
|
EXTRACTED_BINARY="/tmp/network-cli"
|
||||||
|
elif [ -f /tmp/dbn ]; then
|
||||||
|
EXTRACTED_BINARY="/tmp/dbn"
|
||||||
|
else
|
||||||
|
error "Failed to extract binary (neither network-cli nor dbn found)"
|
||||||
ls -la /tmp/ | grep -E "(network|cli|dbn)"
|
ls -la /tmp/ | grep -E "(network|cli|dbn)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod +x /tmp/network-cli
|
chmod +x "$EXTRACTED_BINARY"
|
||||||
|
|
||||||
log "Installing dbn to $INSTALL_DIR..."
|
log "Installing dbn to $INSTALL_DIR..."
|
||||||
# Rename network-cli to dbn during installation
|
# Always rename to dbn during installation
|
||||||
mv /tmp/network-cli "$INSTALL_DIR/dbn"
|
mv "$EXTRACTED_BINARY" "$INSTALL_DIR/dbn"
|
||||||
|
|
||||||
# Sanity check: verify the installed binary is functional and reports correct version
|
# Sanity check: verify the installed binary is functional and reports correct version
|
||||||
if ! "$INSTALL_DIR/dbn" version &>/dev/null; then
|
if ! "$INSTALL_DIR/dbn" version &>/dev/null; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user