Skip to content

[cleaner] Skip Size for directory output - #4459

Open
mahimabhosale wants to merge 1 commit into
sosreport:mainfrom
mahimabhosale:fix-4396-cleaner-directory-size
Open

[cleaner] Skip Size for directory output#4459
mahimabhosale wants to merge 1 commit into
sosreport:mainfrom
mahimabhosale:fix-4396-cleaner-directory-size

Conversation

@mahimabhosale

@mahimabhosale mahimabhosale commented Aug 21, 2026

Copy link
Copy Markdown

sos clean always printed Size from os.stat() of the output path.
For a directory that is inode metadata (commonly 4KiB), not the
obfuscated data size.

Report Size only for packed archives, matching the
archive-vs-directory split in Policy.display_results.

Closes: #4396


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

sos clean always printed Size from os.stat() of the output path.
For a directory that is inode metadata (commonly 4KiB), not the
obfuscated data size.

Report Size only for packed archives, matching the
archive-vs-directory split in Policy.display_results.

Closes: sosreport#4396

Signed-off-by: Mahima Bhosale <mabhosal@redhat.com>
@packit-as-a-service

Copy link
Copy Markdown

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo dnf install -y 'dnf*-command(copr)'
  • dnf copr enable packit/sosreport-sos-4459
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@jcastill jcastill added the Kind/cleaner cleaner component of sos label Aug 25, 2026

@TurboTurtle TurboTurtle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a suggestion, we could still report the cumulative directory size instead of not printing anything.

def get_directory_size(path):
    total_size = 0
    try:
        with os.scandir(path) as flist:
            for _f in flist:
                if _f.is_file(follow_symlinks=False):
                    total_size += _f.stat(follow_symlinks=False).st_size
                elif _f.is_dir(follow_symlinks=False):
                    total_size += get_directory_size(_f.path)
    except PermissionError:
        # ignore these instead of bailing out on size calculation
        pass
    return total_size

get_human_readable(get_directory_size(final_path))

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

Labels

Kind/cleaner cleaner component of sos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cleaner] invalid Size reported when output format is directory

3 participants