Add bindings for Details() download-size property#67
Conversation
📝 WalkthroughWalkthroughThis PR adds a new public accessor method ChangesDownload Size API Extension
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/details.cpp`:
- Around line 70-73: The current PackageKit::Details::downloadSize() returns 0
for both "unknown" and an actual zero-byte download because
value(QLatin1String("download-size")).toULongLong() returns 0 for a default
QVariant; add a companion predicate PackageKit::Details::hasDownloadSize()
(declare in details.h and define in details.cpp) that checks the underlying
QVariant for the "download-size" key using
value(QLatin1String("download-size")).isValid() &&
value(QLatin1String("download-size")).canConvert<qulonglong>() (or equivalent
checks for non-null/convertibility), and update callers to call
hasDownloadSize() before using downloadSize().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 74d0f681-5180-4571-a52a-314c31147005
📒 Files selected for processing (2)
src/details.cppsrc/details.h
| qulonglong PackageKit::Details::downloadSize() const | ||
| { | ||
| return value(QLatin1String("download-size")).toULongLong(); | ||
| } |
There was a problem hiding this comment.
0 is ambiguous: it means both "unknown/unsupported" and "zero bytes to download".
When a backend does not implement pk_backend_job_details_full(), value("download-size") returns a default QVariant and toULongLong() returns 0 — the same value returned for a legitimately zero-byte download. Issue #64 explicitly calls this out as something that must be handled.
The existing size() has the same design, so changing the return type is a bigger API decision; but at minimum consider a companion predicate:
💡 Suggested companion accessor
In details.h:
qulonglong downloadSize() const;
+bool hasDownloadSize() const;In details.cpp:
+bool PackageKit::Details::hasDownloadSize() const
+{
+ return contains(QLatin1String("download-size"));
+}Callers can then do:
if (details.hasDownloadSize())
showDownloadSize(details.downloadSize());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/details.cpp` around lines 70 - 73, The current
PackageKit::Details::downloadSize() returns 0 for both "unknown" and an actual
zero-byte download because value(QLatin1String("download-size")).toULongLong()
returns 0 for a default QVariant; add a companion predicate
PackageKit::Details::hasDownloadSize() (declare in details.h and define in
details.cpp) that checks the underlying QVariant for the "download-size" key
using value(QLatin1String("download-size")).isValid() &&
value(QLatin1String("download-size")).canConvert<qulonglong>() (or equivalent
checks for non-null/convertibility), and update callers to call
hasDownloadSize() before using downloadSize().
|
The rabbit has a point, but we should adjust the API in one go later, using |
Resolves #64.