mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat(database): SQLite database backups (#1756)
* feat(database): SQLite database backups * feat(database): do not produce SQL injections * feat(database): retain all backups if 0 or less refactor(database): specify database driver in func names * refactor(database): return early on cleanup * refactor(database): do not call cleanup func if max backups set to 0 * refactor(database): backup retention behavior * feat(database): improve logging --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
1227657ae8
commit
74eea79215
4 changed files with 146 additions and 12 deletions
|
@ -23,7 +23,9 @@ type DB struct {
|
|||
handler *sql.DB
|
||||
lock sync.RWMutex
|
||||
ctx context.Context
|
||||
cancel func()
|
||||
cfg *domain.Config
|
||||
|
||||
cancel func()
|
||||
|
||||
Driver string
|
||||
DSN string
|
||||
|
@ -36,6 +38,7 @@ func NewDB(cfg *domain.Config, log logger.Logger) (*DB, error) {
|
|||
// set default placeholder for squirrel to support both sqlite and postgres
|
||||
squirrel: sq.StatementBuilder.PlaceholderFormat(sq.Dollar),
|
||||
log: log.With().Str("module", "database").Str("type", cfg.DatabaseType).Logger(),
|
||||
cfg: cfg,
|
||||
}
|
||||
db.ctx, db.cancel = context.WithCancel(context.Background())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue