mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 04:27:37 +03:00
revert: separation of write and read DBs
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
1bf94531fd
commit
3982ba7258
22 changed files with 78 additions and 161 deletions
|
@ -92,9 +92,8 @@ func runBackup(ctx context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
database := db.Db()
|
||||
start := time.Now()
|
||||
path, err := database.Backup(ctx)
|
||||
path, err := db.Backup(ctx)
|
||||
if err != nil {
|
||||
log.Fatal("Error backing up database", "backup path", conf.Server.BasePath, err)
|
||||
}
|
||||
|
@ -138,9 +137,8 @@ func runPrune(ctx context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
database := db.Db()
|
||||
start := time.Now()
|
||||
count, err := database.Prune(ctx)
|
||||
count, err := db.Prune(ctx)
|
||||
if err != nil {
|
||||
log.Fatal("Error pruning up database", "backup path", conf.Server.BasePath, err)
|
||||
}
|
||||
|
@ -177,9 +175,8 @@ func runRestore(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
database := db.Db()
|
||||
start := time.Now()
|
||||
err := database.Restore(ctx, restorePath)
|
||||
err := db.Restore(ctx, restorePath)
|
||||
if err != nil {
|
||||
log.Fatal("Error backing up database", "backup path", conf.Server.BasePath, err)
|
||||
}
|
||||
|
|
|
@ -162,13 +162,12 @@ func schedulePeriodicBackup(ctx context.Context) func() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
database := db.Db()
|
||||
schedulerInstance := scheduler.GetInstance()
|
||||
|
||||
log.Info("Scheduling periodic backup", "schedule", schedule)
|
||||
err := schedulerInstance.Add(schedule, func() {
|
||||
start := time.Now()
|
||||
path, err := database.Backup(ctx)
|
||||
path, err := db.Backup(ctx)
|
||||
elapsed := time.Since(start)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error backing up database", "elapsed", elapsed, err)
|
||||
|
@ -176,7 +175,7 @@ func schedulePeriodicBackup(ctx context.Context) func() error {
|
|||
}
|
||||
log.Info(ctx, "Backup complete", "elapsed", elapsed, "path", path)
|
||||
|
||||
count, err := database.Prune(ctx)
|
||||
count, err := db.Prune(ctx)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error pruning database", "error", err)
|
||||
} else if count > 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue