From 7b83d818203c8cd689f054ec8c43d7a6fa8a6a9f Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Fri, 30 Sep 2022 20:57:28 +1000 Subject: [PATCH] Fix backup issues (#2966) Make backup directory setting optional. Use the basename of the database file for the naming. --- internal/api/resolver_mutation_configure.go | 2 +- pkg/sqlite/database.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/resolver_mutation_configure.go b/internal/api/resolver_mutation_configure.go index 9cf3ac9a4..0252192e7 100644 --- a/internal/api/resolver_mutation_configure.go +++ b/internal/api/resolver_mutation_configure.go @@ -86,7 +86,7 @@ func (r *mutationResolver) ConfigureGeneral(ctx context.Context, input ConfigGen existingBackupDirectoryPath := c.GetBackupDirectoryPath() 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 } diff --git a/pkg/sqlite/database.go b/pkg/sqlite/database.go index 07641c85e..26e4ead8c 100644 --- a/pkg/sqlite/database.go +++ b/pkg/sqlite/database.go @@ -255,7 +255,7 @@ func (db *Database) DatabasePath() 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 != "" { return filepath.Join(backupDirectoryPath, fn)