# Single lsblk call gets everything
try:
result = subprocess.run(
['lsblk', '-d', '-n', '-o', 'NAME,TYPE', '-p'], # Add -p for full paths
stdout=subprocess.PIPE, text=True, timeout=10
)
for line in result.stdout.strip().split('\n'):
if line:
parts = line.split()
if len(parts) >= 2 and parts[1] == 'disk':
disks.add(parts[0]) # Already has /dev/ prefix
return sorted(disks) # Return sorted for consistency
except Exception as e:
logger.error(f"Failed to detect disks: {e}")
return []
_get_all_disks() calls glob.glob() multiple times and uses sets inefficiently:
# Current approach scans filesystem multiple times
for pattern in ['/dev/sd[a-z]', '/dev/nvme[0-9]n[0-9]']:
matches = glob.glob(pattern)
Optimize:
def _get_all_disks(self) -> List[str]:
"""Get all physical disks efficiently."""
disks = set()
# Single lsblk call gets everything
try:
result = subprocess.run(
['lsblk', '-d', '-n', '-o', 'NAME,TYPE', '-p'], # Add -p for full paths
stdout=subprocess.PIPE, text=True, timeout=10
)
for line in result.stdout.strip().split('\n'):
if line:
parts = line.split()
if len(parts) >= 2 and parts[1] == 'disk':
disks.add(parts[0]) # Already has /dev/ prefix
return sorted(disks) # Return sorted for consistency
except Exception as e:
logger.error(f"Failed to detect disks: {e}")
return []
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
_get_all_disks() calls glob.glob() multiple times and uses sets inefficiently:
Current approach scans filesystem multiple times
for pattern in ['/dev/sd[a-z]', '/dev/nvme[0-9]n[0-9]']:
matches = glob.glob(pattern)
Optimize:
def _get_all_disks(self) -> List[str]:
"""Get all physical disks efficiently."""
disks = set()