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");
|
||||
|
||||
@@ -121,6 +121,23 @@ public:
|
||||
// by a provider: they carry a plugin, they are not packages to install, so
|
||||
// they never take the sudo gate and never enter the file install queue.
|
||||
bool isPluginPackage(const QString& path) const;
|
||||
|
||||
// What a file the user drops (or opens with PacManager) would install, and
|
||||
// whether that application is already on the machine. Read before anything
|
||||
// runs, so the view can refuse a file the provider would only skip — or an
|
||||
// install that would silently do nothing — and say why.
|
||||
struct FileTarget {
|
||||
// Application id for a provider file ("com.example.App"), plugin id for
|
||||
// a .fwspacm. Empty when the file names no single application: a
|
||||
// .flatpakrepo registers a remote, and an unreadable file names
|
||||
// nothing at all.
|
||||
QString name;
|
||||
bool installed = false;
|
||||
// A .fwspacm carries a plugin, not a package: the two are refused with
|
||||
// different advice.
|
||||
bool plugin = false;
|
||||
};
|
||||
FileTarget fileTarget(const QString& path) const;
|
||||
// Bulk removal: one command per provider, run one provider at a time
|
||||
// (pacman locks its database for the whole operation).
|
||||
StartResult removePackages(const std::vector<PackageInfo>& packages,
|
||||
|
||||
Reference in new issue
Block a user