feat(files): confirm dropped files and refuse the ones already installed
A drop — or "Ouvrir avec PacManager" — answered nothing: a Flatpak install walked off into the background and a plugin package landed without a sound, so the gesture read as ignored. Both now open a dialog saying what was taken and what it starts. A file the machine already has is refused before anything runs, and named. The application a file would install is read out of the file itself (the [Flatpak Ref] section of a .flatpakref, the header of a .flatpak bundle, the manifest of a .fwspacm) and compared with what the provider has, so nothing is started to find out: Flatpak would otherwise skip the install and report a success the user never got, and a plugin package would silently replace the one in place.
This commit is contained in:
16 files changed
+557
-9
No files matched your search
@@ -544,6 +544,36 @@ bool AppCore::isPluginPackage(const QString& path) const {
|
||||
return PluginPackage::isPackagePath(path);
|
||||
}
|
||||
|
||||
AppCore::FileTarget AppCore::fileTarget(const QString& path) const {
|
||||
FileTarget target;
|
||||
const QString clean = path.trimmed();
|
||||
if (clean.isEmpty()) return target;
|
||||
|
||||
// A plugin package names itself in its own manifest, and the registry knows
|
||||
// whether that plugin is already there. Read only: nothing is written
|
||||
// before the window has decided what to tell the user.
|
||||
if (isPluginPackage(clean)) {
|
||||
QString error;
|
||||
const PluginPackage::Contents contents = PluginPackage::read(clean, &error);
|
||||
if (!error.isEmpty()) return target; // unusable: nothing to announce
|
||||
target.name = contents.manifest.id;
|
||||
target.plugin = true;
|
||||
target.installed = m_packages->isInstalled(target.name);
|
||||
return target;
|
||||
}
|
||||
|
||||
// A provider file: the provider owning the format names the application it
|
||||
// would install, and answers whether it is already deployed.
|
||||
for (IPackageManager* pm : availableProviders()) {
|
||||
const std::string name = pm->fileTargetName(clean.toStdString());
|
||||
if (name.empty()) continue;
|
||||
target.name = QString::fromStdString(name);
|
||||
target.installed = pm->isPackageInstalled(name);
|
||||
return target;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
AppCore::StartResult AppCore::removePackages(const std::vector<PackageInfo>& packages,
|
||||
const QString& description) { Request request;
|
||||
request.action = QStringLiteral("cleanup");
|
||||
|
||||
Reference in new issue
Block a user