Merge pull request #3122 from nichwall/backup_field_prevent_edits_with_env

Prevent backup path edits when ENV is set
This commit is contained in:
advplyr 2024-07-05 16:10:14 -05:00 committed by GitHub
commit 3a2f786517
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 8 deletions

View File

@ -171,7 +171,7 @@ export default {
this.$axios this.$axios
.$get('/api/backups') .$get('/api/backups')
.then((data) => { .then((data) => {
this.$emit('loaded', data.backupLocation) this.$emit('loaded', data)
this.setBackups(data.backups || []) this.setBackups(data.backups || [])
}) })
.catch((error) => { .catch((error) => {

View File

@ -16,11 +16,11 @@
</div> </div>
<div v-else> <div v-else>
<form class="flex items-center w-full space-x-1" @submit.prevent="saveBackupPath"> <form class="flex items-center w-full space-x-1" @submit.prevent="saveBackupPath">
<ui-text-input v-model="newBackupLocation" :disabled="savingBackupPath" class="w-full max-w-[calc(100%-50px)] text-sm h-8" /> <ui-text-input v-model="newBackupLocation" :disabled="savingBackupPath || !canEditBackup" class="w-full max-w-[calc(100%-50px)] text-sm h-8" />
<ui-btn small :loading="savingBackupPath" color="success" type="submit" class="h-8">{{ $strings.ButtonSave }}</ui-btn> <ui-btn v-if="canEditBackup" small :loading="savingBackupPath" color="success" type="submit" class="h-8">{{ $strings.ButtonSave }}</ui-btn>
<ui-btn small :disabled="savingBackupPath" type="button" class="h-8" @click="cancelEditBackupPath">{{ $strings.ButtonCancel }}</ui-btn> <ui-btn small :disabled="savingBackupPath" type="button" class="h-8" @click="cancelEditBackupPath">{{ $strings.ButtonCancel }}</ui-btn>
</form> </form>
<p class="text-sm text-warning/80 pt-1">{{ $strings.MessageBackupsLocationEditNote }}</p> <p class="text-sm text-warning/80 pt-1">{{ canEditBackup ? $strings.MessageBackupsLocationEditNote : $strings.MessageBackupsLocationNoEditNote }}</p>
</div> </div>
</div> </div>
@ -92,6 +92,7 @@ export default {
newServerSettings: {}, newServerSettings: {},
showCronBuilder: false, showCronBuilder: false,
showEditBackupPath: false, showEditBackupPath: false,
backupPathEnvSet: false,
backupLocation: '', backupLocation: '',
newBackupLocation: '', newBackupLocation: '',
savingBackupPath: false savingBackupPath: false
@ -115,6 +116,10 @@ export default {
timeFormat() { timeFormat() {
return this.serverSettings.timeFormat return this.serverSettings.timeFormat
}, },
canEditBackup() {
// Prevent editing of backup path if an environment variable is set
return !this.backupPathEnvSet
},
scheduleDescription() { scheduleDescription() {
if (!this.cronExpression) return '' if (!this.cronExpression) return ''
const parsed = this.$parseCronExpression(this.cronExpression) const parsed = this.$parseCronExpression(this.cronExpression)
@ -127,9 +132,10 @@ export default {
} }
}, },
methods: { methods: {
backupsLoaded(backupLocation) { backupsLoaded(data) {
this.backupLocation = backupLocation this.backupLocation = data.backupLocation
this.newBackupLocation = backupLocation this.newBackupLocation = data.backupLocation
this.backupPathEnvSet = data.backupPathEnvSet
}, },
cancelEditBackupPath() { cancelEditBackupPath() {
this.newBackupLocation = this.backupLocation this.newBackupLocation = this.backupLocation

View File

@ -605,6 +605,7 @@
"MessageAppriseDescription": "To use this feature you will need to have an instance of <a href=\"https://github.com/caronc/apprise-api\" target=\"_blank\">Apprise API</a> running or an api that will handle those same requests. <br />The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at <code>http://192.168.1.1:8337</code> then you would put <code>http://192.168.1.1:8337/notify</code>.", "MessageAppriseDescription": "To use this feature you will need to have an instance of <a href=\"https://github.com/caronc/apprise-api\" target=\"_blank\">Apprise API</a> running or an api that will handle those same requests. <br />The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at <code>http://192.168.1.1:8337</code> then you would put <code>http://192.168.1.1:8337/notify</code>.",
"MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in <code>/metadata/items</code> & <code>/metadata/authors</code>. Backups <strong>do not</strong> include any files stored in your library folders.", "MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in <code>/metadata/items</code> & <code>/metadata/authors</code>. Backups <strong>do not</strong> include any files stored in your library folders.",
"MessageBackupsLocationEditNote": "Note: Updating the backup location will not move or modify existing backups", "MessageBackupsLocationEditNote": "Note: Updating the backup location will not move or modify existing backups",
"MessageBackupsLocationNoEditNote": "Note: The backup location is set through an environment variable and cannot be changed here.",
"MessageBackupsLocationPathEmpty": "Backup location path cannot be empty", "MessageBackupsLocationPathEmpty": "Backup location path cannot be empty",
"MessageBatchQuickMatchDescription": "Quick Match will attempt to add missing covers and metadata for the selected items. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.", "MessageBatchQuickMatchDescription": "Quick Match will attempt to add missing covers and metadata for the selected items. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.",
"MessageBookshelfNoCollections": "You haven't made any collections yet", "MessageBookshelfNoCollections": "You haven't made any collections yet",

View File

@ -10,7 +10,8 @@ class BackupController {
getAll(req, res) { getAll(req, res) {
res.json({ res.json({
backups: this.backupManager.backups.map((b) => b.toJSON()), backups: this.backupManager.backups.map((b) => b.toJSON()),
backupLocation: this.backupManager.backupPath backupLocation: this.backupManager.backupPath,
backupPathEnvSet: this.backupManager.backupPathEnvSet
}) })
} }

View File

@ -29,6 +29,10 @@ class BackupManager {
return global.ServerSettings.backupPath return global.ServerSettings.backupPath
} }
get backupPathEnvSet() {
return !!process.env.BACKUP_PATH
}
get backupSchedule() { get backupSchedule() {
return global.ServerSettings.backupSchedule return global.ServerSettings.backupSchedule
} }