Commit 14cc791d authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

flatpak: Make sure we don't uninstall what we shouldn't

BUG: 458490
parent b3d8fbef
Pipeline #225361 passed with stage
in 1 minute and 14 seconds
......@@ -857,18 +857,29 @@ void FlatpakResource::loadPermissions()
QString FlatpakResource::dataLocation() const
{
auto id = m_appdata.bundle(AppStream::Bundle::KindFlatpak).id();
return QDir::homePath() + QLatin1String("/.var/") + id.section('/', 0, 1);
auto id = m_appdata.bundle(AppStream::Bundle::KindFlatpak).id().section('/', 0, 1);
if (id.isEmpty()) {
return {};
}
return QDir::homePath() + QLatin1String("/.var/") + id;
}
bool FlatpakResource::hasDataButUninstalled() const
{
return m_state == None && QDir(dataLocation()).exists();
return m_state == None && !dataLocation().isEmpty() && QDir(dataLocation()).exists();
}
void FlatpakResource::clearUserData()
{
QDir(dataLocation()).removeRecursively();
const auto location = dataLocation();
if (location.isEmpty()) {
qWarning() << "Failed find location for" << name();
return;
}
if (!QDir(location).removeRecursively()) {
qWarning() << "Failed to remove location" << location;
}
Q_EMIT hasDataButUninstalledChanged();
}
......
Supports Markdown
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