mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ func TestConcurrentConfigAccess(t *testing.T) {
|
||||
i.GetConfigFile()
|
||||
i.GetConfigPath()
|
||||
i.GetDefaultDatabaseFilePath()
|
||||
i.Set(BackupDirectoryPath, i.GetBackupDirectoryPath())
|
||||
i.GetStashPaths()
|
||||
_ = i.ValidateStashBoxes(nil)
|
||||
_ = i.Validate()
|
||||
|
||||
@@ -645,7 +645,14 @@ func (s *Manager) Migrate(ctx context.Context, input MigrateInput) error {
|
||||
// migration fails
|
||||
backupPath := input.BackupPath
|
||||
if backupPath == "" {
|
||||
backupPath = database.DatabaseBackupPath()
|
||||
backupPath = database.DatabaseBackupPath(s.Config.GetBackupDirectoryPath())
|
||||
} else {
|
||||
// check if backup path is a filename or path
|
||||
// filename goes into backup directory, path is kept as is
|
||||
filename := filepath.Base(backupPath)
|
||||
if backupPath == filename {
|
||||
backupPath = filepath.Join(s.Config.GetBackupDirectoryPathOrDefault(), filename)
|
||||
}
|
||||
}
|
||||
|
||||
// perform database backup
|
||||
|
||||
Reference in New Issue
Block a user