fix(update): stamp the installed release so it is not offered twice
The checkout path installed with the build's configured prefix instead of installing into the directory holding the running copy, so the binary in use and its version marker both stayed at the old release: the app kept reporting that version and offered the same update again at every launch. Every method now stages and installs into the running binary's directory, the install step writes the release it just installed next to the binary, and currentVersion() reads the version compiled into the running build first, falling back to the marker file. The repo-root `version` file stays the single source of truth: CMake compiles it in. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
1 parent
632cdf1dea
commit
5756704b03
5 files changed
+132
-42
No files matched your search
@@ -13,7 +13,8 @@
|
||||
// the directory that holds the running executable, wherever that is
|
||||
// (~/.local/bin, /usr/bin, an arbitrary extracted folder, a build tree...).
|
||||
// The strategy is picked by updateMethod():
|
||||
// - Checkout: a source checkout around the binary is pulled + rebuilt;
|
||||
// - Checkout: a source checkout around the binary is pulled + rebuilt, then
|
||||
// installed into the running binary's directory like the other methods;
|
||||
// - Clone: installed without a checkout, the repo is cloned (then pulled)
|
||||
// into ~/.local/share/PacManager/src, built, and installed in place;
|
||||
// - Prebuilt: the release's prebuilt archive is unpacked (no compiler);
|
||||
@@ -25,7 +26,9 @@ class UpdateManager : public QObject {
|
||||
public:
|
||||
explicit UpdateManager(QObject* parent = nullptr);
|
||||
|
||||
// Current app version, read from the version file at build time.
|
||||
// Current app version, compiled in from the repo-root `version` file (see
|
||||
// CMakeLists.txt), falling back to the `version` file installed next to the
|
||||
// executable when the build bypassed CMake.
|
||||
static QString currentVersion();
|
||||
|
||||
// Path of the state file storing the last check date and the latest
|
||||
@@ -135,13 +138,14 @@ private:
|
||||
void saveState(const QString& remoteVersion);
|
||||
void loadState();
|
||||
void runShell(const QString& script, const QString& workingDir);
|
||||
void performCheckoutUpdate();
|
||||
void performCheckoutUpdate(const QString& sudoPassword);
|
||||
void performCloneUpdate(const QString& sudoPassword);
|
||||
void performPrebuiltUpdate(const QString& sudoPassword);
|
||||
void performTarballUpdate(const QString& sudoPassword);
|
||||
// Shared script header for the installed (no checkout) paths: temp work
|
||||
// dir, cleanup trap, and the export of the paths the install step needs.
|
||||
QString installedScriptPrologue() const;
|
||||
// Shared script header for every update path: temp work dir, cleanup trap,
|
||||
// the release being installed, and the export of the paths the install step
|
||||
// needs.
|
||||
QString updateScriptPrologue() const;
|
||||
// Copy command that installs a staged tree ($STAGE/bin) into the running
|
||||
// binary's directory, wrapped in sudo when the target is not writable.
|
||||
QString installCommand(const QString& quotedPassword,
|
||||
|
||||
Reference in new issue
Block a user