Skip to content

Spaces without a quota limit display "undefined" as the storage line #950

@greve

Description

@greve

Summary

Ran into this when packaging OpenCloud Desktop for Fedora COPR:

For a Space whose quota is unlimited (server reports total == 0), the folder/Space list shows the literal text undefined where the storage usage line should be usage only, or be hidden. The account otherwise connects and syncs normally; only the storage label is wrong.

Steps to reproduce

  1. Connect the client to an OpenCloud server whose Spaces have no quota limit (capabilities: "spaces":{"max_quota":0,…}; GET /graph/v1.0/me/drives returns drives whose quota.total is 0/absent).
  2. Open the account view that lists the Spaces.

Expected behavior

  • no storage line (or an "unlimited" indication) for unlimited Spaces.

Actual behavior

  • the storage line reads undefined.

Setup

Root cause

src/gui/folderstatusmodel.cpp, FolderStatusModel::data(), Roles::Quota:

case Roles::Quota: {
    qint64 used{};
    qint64 total{};
    if (auto *space = f->space()) {
        const auto quota = space->drive().getQuota();
        if (quota.isValid()) {
            used = quota.getUsed();
            total = quota.getTotal();
        }
    }
    if (total <= 0) {
        return {};   // <-- invalid QVariant()
    }
    return tr("%1 of %2 used").arg(Utility::octetsToString(used), Utility::octetsToString(total));
}

The role is consumed in src/gui/qml/FolderDelegate.qml as a typed string:

required property string quota
...
text: folderDelegate.quota
visible: folderDelegate.quota && !folderDelegate.overallText

When total <= 0, data() returns an invalid QVariant(). Assigned to a required property string, that becomes the JS value undefined, which stringifies to the literal "undefined". The visible: guard then sees a non-empty (truthy) string and shows the label. An empty QString would instead coerce to "", which the guard treats as false and hides as a minimal fix.

The invalid-variant → string coercion is stricter on newer Qt (seen with Qt 6.11); the underlying defect: returning an invalid variant for a role bound to a typed string property is version-independent.

Suggested fix (one line)

         if (total <= 0) {
-            return {};
+            return QString();
         }

This hides the storage line for unlimited Spaces via the existing visible: guard. (A follow-up could instead show "X used" or an "Unlimited" label, but the minimal correctness fix is to stop rendering undefined.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions