Add backup directory path setting (#2953)

* add backup directory path setting
* Don't default backup path
* handle migration backup path input when given filename or path

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
7dJx1qP
2022-09-29 20:00:50 -04:00
committed by GitHub
parent ad7fbce5f7
commit d274f86390
12 changed files with 78 additions and 14 deletions

View File

@@ -26,15 +26,16 @@ import (
var officialBuild string
const (
Stash = "stash"
Cache = "cache"
Generated = "generated"
Metadata = "metadata"
Downloads = "downloads"
ApiKey = "api_key"
Username = "username"
Password = "password"
MaxSessionAge = "max_session_age"
Stash = "stash"
Cache = "cache"
BackupDirectoryPath = "backup_directory_path"
Generated = "generated"
Metadata = "metadata"
Downloads = "downloads"
ApiKey = "api_key"
Username = "username"
Password = "password"
MaxSessionAge = "max_session_age"
DefaultMaxSessionAge = 60 * 60 * 1 // 1 hours
@@ -525,6 +526,19 @@ func (i *Instance) GetDatabasePath() string {
return i.getString(Database)
}
func (i *Instance) GetBackupDirectoryPath() string {
return i.getString(BackupDirectoryPath)
}
func (i *Instance) GetBackupDirectoryPathOrDefault() string {
ret := i.GetBackupDirectoryPath()
if ret == "" {
return i.GetConfigPath()
}
return ret
}
func (i *Instance) GetJWTSignKey() []byte {
return []byte(i.getString(JWTSignKey))
}
@@ -1351,6 +1365,7 @@ func (i *Instance) setDefaultValues(write bool) error {
// Set default scrapers and plugins paths
i.main.SetDefault(ScrapersPath, defaultScrapersPath)
i.main.SetDefault(PluginsPath, defaultPluginsPath)
if write {
return i.main.WriteConfig()
}