fix: USB badge detection for bind-mounted drives + graceful Tier2 backup on disconnected destinations
- IsUSBDevice/diskModel: strip findmnt bind-mount suffix [/subdir] before parsing device path (fixes USB badge not showing for attach-wizard drives) - crossdrive.go: skip disconnected src/dest drives with WARN log instead of returning error (prevents noisy error status in settings.json) - handlers.go: detect Tier2 destination disconnection, set yellow status dot instead of red, skip ValidateDestination for disconnected paths - backups.html: new template branch showing "Cél meghajtó leválasztva" badge with grayed-out info and hidden "Futtatás most" button Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -248,6 +248,10 @@ func stripPartition(base string) string {
|
||||
|
||||
// diskModel reads the disk model from /sys/block/<dev>/device/model.
|
||||
func diskModel(device string) string {
|
||||
// Strip bind-mount subdir suffix (e.g., "/dev/sdb1[/felhom_data]" → "/dev/sdb1")
|
||||
if idx := strings.IndexByte(device, '['); idx >= 0 {
|
||||
device = device[:idx]
|
||||
}
|
||||
disk := stripPartition(filepath.Base(device))
|
||||
modelPath := "/sys/block/" + disk + "/device/model"
|
||||
data, err := os.ReadFile(modelPath)
|
||||
@@ -321,8 +325,13 @@ func ProbeStoragePath(path string) ProbeResult {
|
||||
|
||||
// IsUSBDevice checks if a block device is connected via USB.
|
||||
// devicePath should be like "/dev/sdb" or "/dev/sdb1".
|
||||
// Also handles bind-mount suffixes from findmnt (e.g., "/dev/sdb1[/felhom_data]").
|
||||
// Checks the sysfs symlink for the disk — if the path contains "/usb", it's a USB device.
|
||||
func IsUSBDevice(devicePath string) bool {
|
||||
// Strip bind-mount subdir suffix (e.g., "/dev/sdb1[/felhom_data]" → "/dev/sdb1")
|
||||
if idx := strings.IndexByte(devicePath, '['); idx >= 0 {
|
||||
devicePath = devicePath[:idx]
|
||||
}
|
||||
disk := stripPartition(filepath.Base(devicePath))
|
||||
if disk == "" {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user