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:
BlackAngelTV committed 2026-10-09 19:22:24 +02:00
1 parent f4aa661b54
commit 55718064a6
16 files changed
+557 -9

No files matched your search

+31
View File
@@ -2,6 +2,7 @@
#include <QCoreApplication>
#include <QDir>
#include <QFile>
#include <QStringList>
#include <QTemporaryDir>
@@ -252,6 +253,35 @@ void testDatabaseLockIsQueryable() {
}
}
// What a file the user drops would install. Only the half that needs no
// provider is asserted here (the Flatpak side is covered by that provider's own
// test, on the bytes a bundle really carries): an unreadable package names
// nothing, so the window installs it and lets the reader report the reason.
void testFileTargetAnswersNothingForWhatItCannotRead() {
AppCore core;
assert(core.fileTarget(QString()).name.isEmpty());
assert(!core.fileTarget(QString()).installed);
assert(!core.fileTarget(QStringLiteral(" ")).installed);
// No provider claims a text document, so there is nothing to name.
assert(core.fileTarget(QStringLiteral("/tmp/liste-de-courses.txt")).name.isEmpty());
QTemporaryDir dir;
assert(dir.isValid());
const QString broken = dir.filePath(QStringLiteral("casse.fwspacm"));
QFile file(broken);
assert(file.open(QIODevice::WriteOnly));
file.write("pas une archive");
file.close();
const AppCore::FileTarget target = core.fileTarget(broken);
assert(target.name.isEmpty());
assert(!target.installed);
// It is still a plugin package by its name, which is what the window asks
// next before handing it to the installer.
assert(core.isPluginPackage(broken));
}
} // namespace
int main(int argc, char* argv[]) {
@@ -282,6 +312,7 @@ int main(int argc, char* argv[]) {
testLogReadReportsItsFailure();
testUpdateStateIsReadableWithoutRunningAnything();
testDatabaseLockIsQueryable();
testFileTargetAnswersNothingForWhatItCannotRead();
std::cout << "app-core: all tests passed" << std::endl;
return 0;