feat(pacman): close the manager holding the database lock instead of waiting
A locked database ended in "Un autre gestionnaire de paquets utilise déjà la base. Attendez la fin de l'autre opération puis réessayez": the app knew something else was running but could not say what, leaving the user to find and close it before retrying by hand. The lock is now inspected: the process holding /var/lib/pacman/db.lck is identified through /proc (with a pgrep fallback for the known managers, whose fd table is unreadable when they run as root), the dialog names it, and one click stops it — SIGTERM first, so pacman aborts its transaction and releases the lock itself, SIGKILL only when it does not react — then the pending operation resumes on its own. A lock whose owner is gone is dropped the same way, and one that disappears while the action is unwinding is retried without a dialog at all. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
d8bc17b2aa
commit
fb5c11e153
7 files changed
+517
-28
No files matched your search
+24
-1
@@ -71,12 +71,25 @@ private:
|
||||
class InstallWorker : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Op { Install, Remove, Update, UpdateAll, Refresh, RemovePackages, CleanCache };
|
||||
enum class Op {
|
||||
Install,
|
||||
Remove,
|
||||
Update,
|
||||
UpdateAll,
|
||||
Refresh,
|
||||
RemovePackages,
|
||||
CleanCache,
|
||||
ReleaseLock,
|
||||
};
|
||||
InstallWorker(IPackageManager* pm, Op op, const std::string& package);
|
||||
// Bulk variant: removes several packages in one provider call (cleanup
|
||||
// page) instead of one call per package.
|
||||
InstallWorker(IPackageManager* pm, Op op, const std::vector<std::string>& packages);
|
||||
InstallWorker(const std::vector<IPackageManager*>& providers, Op op);
|
||||
// Pacman database-lock recovery: stops whatever holds the lock, or drops a
|
||||
// stale lock file. Runs off the UI thread because waiting for the other
|
||||
// manager to exit takes seconds.
|
||||
InstallWorker(PacmanManager* pacman, const PacmanManager::LockHolder& holder);
|
||||
void run() override;
|
||||
signals:
|
||||
void progress(const QString& message);
|
||||
@@ -89,6 +102,8 @@ private:
|
||||
Op m_op;
|
||||
std::string m_package;
|
||||
std::vector<std::string> m_packages;
|
||||
PacmanManager* m_pacman = nullptr; // lock recovery only
|
||||
PacmanManager::LockHolder m_lockHolder;
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
@@ -181,6 +196,14 @@ private:
|
||||
// a retry once the lock is gone).
|
||||
bool showProviderError(const QString& title, IPackageManager* provider);
|
||||
|
||||
// Names the process holding pacman's database and offers to close it — or to
|
||||
// drop a stale lock — before re-running the pending action. Returns true when
|
||||
// it handled the failure, so the caller skips its own reporting.
|
||||
bool handleDatabaseLock(const QString& title);
|
||||
void startLockRecovery(const PacmanManager::LockHolder& holder);
|
||||
// Re-runs the action that failed, when it can still run.
|
||||
void retryPendingAction();
|
||||
|
||||
// Re-runs the given privileged action. Used by the "Réessayer" button
|
||||
// on db-lock errors: the lock (other manager / stale db.lck) is often
|
||||
// gone by the time the user retries.
|
||||
|
||||
Reference in new issue
Block a user