Skip to content

Conversation

@brianmatzelle
Copy link

Summary

This PR fixes the disk usage reporting issues where gtop would often display incorrect partition information by improving the partition selection logic in disk.js.

Problem

The original implementation simply used data[0] (the first filesystem returned by systeminformation), which often pointed to system partitions, swap files, or other irrelevant filesystems instead of the main user data partition. This caused significant discrepancies between gtop's reported disk usage and what users would see in system tools like df or macOS Storage Management.

Solution

The improved implementation:

  1. Filters out small filesystems (< 100MB) to avoid system partitions, swap files, and other non-user-data filesystems
  2. Platform-specific logic:
    • macOS: Prioritizes /System/Volumes/Data (Catalina+), then / (root), then falls back to the largest filesystem
    • Linux/Unix: Prioritizes / (root filesystem), then falls back to the largest filesystem
  3. Intelligent fallback: If no suitable filesystem is found, falls back to the original behavior

Issues Fixed

This addresses several reported issues:

Changes Made

  • Enhanced updateData() function in lib/monitor/disk.js
  • Added filesystem filtering logic to exclude system partitions
  • Implemented platform-specific partition selection
  • Maintained backward compatibility with fallback logic

Testing

The changes have been tested to ensure:

  • Proper root filesystem detection on Linux systems
  • Correct handling of macOS filesystem structure (including Catalina+)
  • Fallback behavior works when expected filesystems aren't found
  • No breaking changes to existing functionality

This improvement makes gtop's disk usage reporting much more accurate and consistent with standard system tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant