fix(flatpak): per-user install fallback and real error reporting
Installing through a system-wide remote fails under polkit and, when a
remote exists in both installations, flatpak refuses non-interactive
installs ("Multiple remotes have refs matching"). Retry with an explicit
`--user flathub` target, refresh appstream metadata before giving up on
stale refs, and let update/refresh fall back to the user installation as
well. Expose the last command output through IPackageManager::lastError
and show it in a dialog on failure instead of failing silently.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
7 files changed
+144
-15
No files matched your search
@@ -22,6 +22,9 @@ public:
|
||||
return system("which flatpak > /dev/null 2>&1") == 0;
|
||||
}
|
||||
|
||||
// Last lines of the failed command output, shown to the user on failure.
|
||||
std::string lastError() const override { return m_lastError; }
|
||||
|
||||
// Parse `flatpak search` output (one whitespace-aligned row per app:
|
||||
// "Name Description Application ID Version Branch Remotes").
|
||||
// Exposed as static so the parsing can be unit-tested without flatpak.
|
||||
@@ -48,4 +51,6 @@ public:
|
||||
|
||||
private:
|
||||
bool isInstalled(const std::string& appId);
|
||||
|
||||
std::string m_lastError;
|
||||
};
|
||||
@@ -119,6 +119,10 @@ private:
|
||||
// first available provider when the tag is unknown or empty.
|
||||
IPackageManager* providerFor(const std::string& id) const;
|
||||
|
||||
// Show the provider's last error in a dialog when one is available, so a
|
||||
// failed operation explains itself instead of failing silently.
|
||||
void showProviderError(const QString& title, IPackageManager* provider);
|
||||
|
||||
void setupUI();
|
||||
void setupSidebar();
|
||||
void setupHeader();
|
||||
|
||||
@@ -143,6 +143,11 @@ public:
|
||||
// Whether privileged operations need a password (e.g. sudo for pacman).
|
||||
// Providers that run per-user (e.g. flatpak) can keep the default.
|
||||
virtual bool requiresPassword() const { return false; }
|
||||
|
||||
// Last error reported by the most recent failed operation, if any. Used
|
||||
// to surface the real command output to the user instead of a generic
|
||||
// failure message.
|
||||
virtual std::string lastError() const { return {}; }
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user