MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _clear_git_locks

Function _clear_git_locks

webapp_modern.py:9268–9315  ·  view source on GitHub ↗

Remove EVERY stale *.lock under .git — not just the old hardcoded short list (index.lock/HEAD.lock/shallow.lock/refs/heads/main.lock). The locks that actually got stuck and forced users to stop the service and delete files by hand were the ones NOT on that list: refs/remotes/origin/

(repo_path: str, warnings: list)

Source from the content-addressed store, hash-verified

9266 db = get_db(currentdir=shared_data.currentdir)
9267 hosts = db.get_all_hosts()
9268
9269 logger.info(f"[SQLITE SYNC] Reading from SQLite database")
9270
9271 for host in hosts:
9272 ip = host.get("ip", "").strip()
9273 mac = host.get("mac", "").strip()
9274
9275 # Skip standalone entries or entries without IP
9276 if mac == "STANDALONE" or not ip:
9277 continue
9278
9279 # Get status from database (alive or degraded)
9280 status = host.get("status", "alive")
9281 failed_pings = host.get("failed_ping_count", 0)
9282
9283 # Host is active if status is 'alive' (0-29 failed pings)
9284 # Host is inactive/degraded if status is 'degraded' (30+ failed pings)
9285 is_active = (status == 'alive')
9286
9287 if mac:
9288 discovered_macs.add(mac)
9289
9290 # Count all hosts for total
9291 total_target_count += 1
9292
9293 # Count active hosts
9294 if is_active:
9295 aggregated_targets += 1
9296
9297 # Count all port instances - support both comma (SQLite) and semicolon (CSV) delimiters
9298 ports_str = host.get('ports', '')
9299 if ports_str and ports_str != '0':
9300 # Check for comma first (SQLite format), else semicolon (CSV format)
9301 if ',' in ports_str:
9302 port_list = [p.strip() for p in ports_str.split(',') if p.strip() and p.strip() != '0']
9303 else:
9304 port_list = [p.strip() for p in ports_str.split(';') if p.strip() and p.strip() != '0']
9305
9306 # Count valid numeric ports
9307 valid_ports = [p for p in port_list if p.isdigit()]
9308 aggregated_ports += len(valid_ports)
9309 port_list = valid_ports # Use only valid ports for snapshot
9310
9311 # Track for debugging
9312 if len(valid_ports) > 0:
9313 hostname = host.get('hostname', '')
9314 port_debug_info.append(f"{ip} ({hostname}): {len(valid_ports)} ports [{','.join(valid_ports)}]")
9315 else:
9316 port_list = []
9317
9318 # Track in snapshot

Callers 3

_prepare_git_repoFunction · 0.85
_execute_git_updateFunction · 0.85
check_updatesFunction · 0.85

Calls 4

debugMethod · 0.80
appendMethod · 0.80
warningMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected