Commit a0128388 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

flatpak: delay app size calculation

Only do it when we need it instead of fetching them all at start.
parent 53c31b01
......@@ -541,9 +541,6 @@ void FlatpakBackend::addResource(FlatpakResource *resource)
updateAppState(resource);
// This will update also metadata (required runtime)
updateAppSize(resource);
m_resources.insert(resource->uniqueId(), resource);
if (!resource->extends().isEmpty()) {
m_extends.append(resource->extends());
......
......@@ -56,6 +56,8 @@ public:
FlatpakSourcesBackend *sources() const { return m_sources; }
bool updateAppSize(FlatpakResource *resource);
private Q_SLOTS:
void onFetchMetadataFinished(FlatpakResource *resource, const QByteArray &metadata);
void onFetchSizeFinished(FlatpakResource *resource, guint64 downloadSize, guint64 installedSize);
......@@ -88,7 +90,6 @@ private:
bool updateAppMetadata(FlatpakResource *resource);
bool updateAppMetadata(FlatpakResource *resource, const QByteArray &data);
bool updateAppMetadata(FlatpakResource *resource, const QString &path);
bool updateAppSize(FlatpakResource *resource);
bool updateAppSizeFromRemote(FlatpakResource *resource);
void updateAppState(FlatpakResource *resource);
......
......@@ -350,6 +350,7 @@ QString FlatpakResource::sizeDescription()
KFormat f;
if (!isInstalled() || canUpgrade()) {
if (propertyState(DownloadSize) == NotKnownYet || propertyState(InstalledSize) == NotKnownYet || propertyState(DownloadSize) == Fetching || propertyState(InstalledSize) == Fetching) {
qobject_cast<FlatpakBackend*>(backend())->updateAppSize(this);
return i18n("Retrieving size information");
} else if (propertyState(DownloadSize) == UnknownOrFailed || propertyState(InstalledSize) == UnknownOrFailed) {
return i18n("Unknown size");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment