From fb3c2fc33b309ab2c7736d018d121049251aaed6 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Mon, 8 Apr 2019 02:14:37 +0100 Subject: [PATCH] Disable installing internal updates when installed with dpkg --- client/src/modules/globals.js | 4 ++++ client/src/modules/updater.js | 4 ++-- client/src/ui/components/bd/UpdaterStatus.vue | 5 +++-- client/src/ui/components/bd/UpdaterView.vue | 20 ++++++++++++++----- core/src/main.js | 5 ++++- core/src/modules/config.js | 8 +++++++- core/src/modules/updater.js | 10 ++++++++++ 7 files changed, 45 insertions(+), 11 deletions(-) diff --git a/client/src/modules/globals.js b/client/src/modules/globals.js index 98618c72..220cf525 100644 --- a/client/src/modules/globals.js +++ b/client/src/modules/globals.js @@ -101,4 +101,8 @@ export default new class extends Module { return this.config.versions.core; } + get disableUpdater() { + return this.config.disableUpdater; + } + } diff --git a/client/src/modules/updater.js b/client/src/modules/updater.js index a48c32c8..41f41240 100644 --- a/client/src/modules/updater.js +++ b/client/src/modules/updater.js @@ -98,7 +98,7 @@ export default new class extends Module { update.text = `${update.id.charAt(0).toUpperCase()}${update.id.slice(1)}`; update.hint = `Current: ${update.currentVersion} | Latest: ${update.version}`; update.status = { - update: true, + update: !Globals.disableUpdater.includes(update.id), updating: false, updated: false, error: null @@ -164,7 +164,7 @@ export default new class extends Module { } toggleUpdate(update) { - update.status.update = !update.status.update; + update.status.update = !update.status.update && !Globals.disableUpdater.includes(update.id); } async startUpdate() { diff --git a/client/src/ui/components/bd/UpdaterStatus.vue b/client/src/ui/components/bd/UpdaterStatus.vue index 76ef0b24..3439e59a 100644 --- a/client/src/ui/components/bd/UpdaterStatus.vue +++ b/client/src/ui/components/bd/UpdaterStatus.vue @@ -12,7 +12,8 @@

{{item.text}}

-

Update Failed!

+

Use your package manager to install

+

Update Failed!

Done

Unknown

@@ -23,6 +24,6 @@ diff --git a/client/src/ui/components/bd/UpdaterView.vue b/client/src/ui/components/bd/UpdaterView.vue index e9457d9a..a0c63f21 100644 --- a/client/src/ui/components/bd/UpdaterView.vue +++ b/client/src/ui/components/bd/UpdaterView.vue @@ -18,15 +18,14 @@
- +
-
- Update -
+ + Update @@ -37,6 +36,7 @@ import SettingsWrapper from './SettingsWrapper.vue'; import UpdaterToggle from './UpdaterToggle.vue'; import UpdaterStatus from './UpdaterStatus.vue'; + import FormButton from '../common/FormButton.vue'; export default { data() { @@ -49,7 +49,8 @@ components: { SettingsWrapper, UpdaterToggle, - UpdaterStatus + UpdaterStatus, + FormButton }, computed: { updatesAvailable() { @@ -66,11 +67,20 @@ }, bdUpdates() { return this.updater.bdUpdates; + }, + updatesSelected() { + return this.updater.updates.bd.find(update => update.status.update); + }, + updating() { + return this.updater.updates.bd.find(update => update.status.updating); } }, methods: { update() { this.updater.startUpdate(); + }, + isDisabled(update) { + return Globals.disableUpdater.includes(update.id); } } } diff --git a/core/src/main.js b/core/src/main.js index 85c6dd1a..2cb6e69c 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -38,7 +38,10 @@ const TEST_ARGS = () => { 'editor': path.resolve(_basePath, 'editor', 'dist'), // tmp: path.join(_basePath, 'tmp') tmp: path.join(os.tmpdir(), 'betterdiscord', `${process.getuid()}`) - } + }, + disableUpdater: [ + 'core', 'client', 'editor' + ] } } const TEST_EDITOR = TESTS && true; diff --git a/core/src/modules/config.js b/core/src/modules/config.js index 43559729..b38e4e95 100644 --- a/core/src/modules/config.js +++ b/core/src/modules/config.js @@ -66,7 +66,8 @@ export default class Config extends Module { return { version: this.version, versions: this.versions, - paths: this.paths + paths: this.paths, + disableUpdater: this.disableUpdater }; } @@ -74,4 +75,9 @@ export default class Config extends Module { compatibility() { this.args.paths = Object.entries(this.args.paths).map(([id, path]) => ({ id, path })); } + + get disableUpdater() { + return this.args.disableUpdater || (this.args.disableUpdater = []); + } + } diff --git a/core/src/modules/updater.js b/core/src/modules/updater.js index 786583d1..72ffc444 100644 --- a/core/src/modules/updater.js +++ b/core/src/modules/updater.js @@ -90,6 +90,10 @@ export default class Updater extends Module { async updateBd(update) { try { + if (this.bd.config.disableUpdater.includes(update.id)) { + throw {message: `Not installing ${update.id} as updates are disabled. Use your package manager to install updates instead.`}; + } + console.log('[BetterDiscord:Updater] Updating', update.id); await this.downloadTarGz(`https://github.com/JsSucks/BetterDiscordApp${update.remote}`, this.bd.config.getPath('base')); this.updateFinished(update); @@ -117,6 +121,12 @@ export default class Updater extends Module { // TODO cleaner if (bd.length) { for (const update of bd) { + if (this.bd.config.disableUpdater.includes(update.id)) { + update.error = {message: `Not installing ${update.id} as updates are disabled. Use your package manager to install updates instead.`}; + this.bd.sendToDiscord('updater-updateError', update); + continue; + } + try { await FileUtils.rm(`${this.bd.config.getPath(update.id)}_old`); // Try to rename dirs first