fix: increase sleep to 5s to reduce rare detach_disk failures

Rare detach_disk failures can still occur even after 10 attempts.
Increasing the sleep duration to 5 seconds reduces the likelihood of these intermittent failures.
This commit is contained in:
LongQT-sea committed 2025-12-16 17:44:26 +07:00
1 parent a18fab6079
commit e1c5fdac4a
1 file changed
+1 -2
+1 -2
View File
@@ -99,12 +99,11 @@ detach_disk() {
for attempt in $(seq 1 "$RETRIES_COUNT"); do
log_info "Detach attempt $attempt of $RETRIES_COUNT..."
if hdiutil detach "$disk" 2>/dev/null || hdiutil detach "$disk" -force 2>/dev/null; then
if sync && sleep 5 && hdiutil detach "$disk" 2>/dev/null || hdiutil detach "$disk" -force 2>/dev/null; then
log_info "Disk detached successfully"
return 0
fi
[ "$attempt" -lt "$RETRIES_COUNT" ] && log_warn "Detach failed, retrying..."
sleep 2
done
log_error "Failed to detach $disk after $RETRIES_COUNT attempts"