Disable installing internal updates when installed with dpkg

This commit is contained in:
Samuel Elliott 2019-04-08 02:14:37 +01:00
parent 840b356885
commit fb3c2fc33b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
7 changed files with 45 additions and 11 deletions

View File

@ -101,4 +101,8 @@ export default new class extends Module {
return this.config.versions.core;
}
get disableUpdater() {
return this.config.disableUpdater;
}
}

View File

@ -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() {

View File

@ -12,7 +12,8 @@
<div class="bd-settingSwitch">
<div class="bd-title">
<h3>{{item.text}}</h3>
<h3 class="bd-updaterStatus bd-err" v-if="item.status.error">Update Failed!</h3>
<h3 class="bd-updaterStatus" v-if="disabled">Use your package manager to install</h3>
<h3 class="bd-updaterStatus bd-err" v-else-if="item.status.error">Update Failed!</h3>
<h3 class="bd-updaterStatus bd-ok" v-else-if="item.status.updated">Done</h3>
<div class="bd-spinner7" v-else-if="item.status.updating" />
<h3 class="bd-updaterStatus" v-else>Unknown</h3>
@ -23,6 +24,6 @@
<script>
export default {
props: ['item']
props: ['item', 'disabled']
}
</script>

View File

@ -18,15 +18,14 @@
</div>
<div class="bd-formDivider"></div>
<div v-for="update in bdUpdates">
<UpdaterStatus :item="update" v-if="update.status.updating" />
<UpdaterStatus :item="update" :disabled="isDisabled(update)" v-if="update.status.updating || isDisabled(update)" />
<UpdaterToggle :item="update" :toggle="() => updater.toggleUpdate(update)" v-else />
<div class="bd-formDivider"></div>
</div>
</div>
</div>
<div class="bd-formButton bd-button" @click="update">
Update
</div>
<FormButton @click="update" :disabled="!updatesSelected || updating">Update</FormButton>
</div>
</SettingsWrapper>
</template>
@ -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);
}
}
}

View File

@ -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;

View File

@ -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 = []);
}
}

View File

@ -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