Skip to content

Fix uploadFilesize check: use >= comparison instead of string equality#27

Merged
BornToBeRoot merged 3 commits intomainfrom
copilot/make-python3-compatible
Apr 1, 2026
Merged

Fix uploadFilesize check: use >= comparison instead of string equality#27
BornToBeRoot merged 3 commits intomainfrom
copilot/make-python3-compatible

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

The uploadFilesize check used strict string equality against calc_size_suffix() output, meaning any value above the threshold (or any formatting difference) would trigger a false CRITICAL. The check should pass as long as the server's limit meets or exceeds the specified minimum.

Changes

  • New convert_size_to_bytes() — converts human-readable size strings (512.0MiB, 1GiB, 2 gigabytes, etc.) to bytes; handles IEC binary (KiB/MiB/…), decimal abbreviations (KB/MB/…), full words, and plural forms
  • uploadFilesize comparison — changed from == string match to convert_size_to_bytes(actual) >= convert_size_to_bytes(expected) numeric comparison
  • OK message — now reports both values: OK - Upload max filesize: 1.0GiB >= 512.0MiB
# Before: only passed if calc_size_suffix() output matched exactly
if options.upload_filesize == upload_max_filesize:

# After: passes if actual >= expected (in bytes)
if convert_size_to_bytes(upload_max_filesize) >= convert_size_to_bytes(options.upload_filesize):

Implements the logic from PR #12 with Python 3 compatibility.

Close #12

@BornToBeRoot BornToBeRoot marked this pull request as ready for review April 1, 2026 20:22
Copilot AI review requested due to automatic review settings April 1, 2026 20:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the uploadFilesize check to compare numeric byte values (minimum required vs. server-reported limit) instead of requiring an exact string match, preventing false CRITICAL results due to formatting differences or higher-than-minimum limits.

Changes:

  • Added convert_size_to_bytes() to parse human-readable size strings into byte counts.
  • Updated uploadFilesize logic from strict string equality to a >= numeric comparison.
  • Adjusted the OK output to show both the actual and expected configured values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread check_nextcloud.py Outdated
Comment thread check_nextcloud.py Outdated
BornToBeRoot and others added 2 commits April 1, 2026 22:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BornToBeRoot BornToBeRoot merged commit 879473a into main Apr 1, 2026
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.

3 participants