Fix backup issues (#2966)

Make backup directory setting optional. Use the basename of the database file for the naming.
This commit is contained in:
WithoutPants 2022-09-30 20:57:28 +10:00 committed by GitHub
parent 9e44e13f6d
commit 7b83d81820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -86,7 +86,7 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen
existingBackupDirectoryPath := c.GetBackupDirectoryPath() existingBackupDirectoryPath := c.GetBackupDirectoryPath()
if input.BackupDirectoryPath != nil && existingBackupDirectoryPath != *input.BackupDirectoryPath { if input.BackupDirectoryPath != nil && existingBackupDirectoryPath != *input.BackupDirectoryPath {
if err := validateDir(config.BackupDirectoryPath, *input.BackupDirectoryPath, false); err != nil { if err := validateDir(config.BackupDirectoryPath, *input.BackupDirectoryPath, true); err != nil {
return makeConfigGeneralResult(), err return makeConfigGeneralResult(), err
} }

View File

@ -255,7 +255,7 @@ func (db *Database) DatabasePath() string {
} }
func (db *Database) DatabaseBackupPath(backupDirectoryPath string) string { func (db *Database) DatabaseBackupPath(backupDirectoryPath string) string {
fn := fmt.Sprintf("%s.%d.%s", db.dbPath, db.schemaVersion, time.Now().Format("20060102_150405")) fn := fmt.Sprintf("%s.%d.%s", filepath.Base(db.dbPath), db.schemaVersion, time.Now().Format("20060102_150405"))
if backupDirectoryPath != "" { if backupDirectoryPath != "" {
return filepath.Join(backupDirectoryPath, fn) return filepath.Join(backupDirectoryPath, fn)