diff --git a/internal/db/postgres/cmd/restore.go b/internal/db/postgres/cmd/restore.go index e7cdce45..a6ec034a 100644 --- a/internal/db/postgres/cmd/restore.go +++ b/internal/db/postgres/cmd/restore.go @@ -141,12 +141,8 @@ func (r *Restore) Run(ctx context.Context) error { } func (r *Restore) putDumpId(task restorers.RestoreTask) { - tableTask, ok := task.(*restorers.TableRestorer) - if !ok { - return - } r.mx.Lock() - r.restoredDumpIds[tableTask.Entry.DumpId] = true + r.restoredDumpIds[task.GetEntry().DumpId] = true r.mx.Unlock() } diff --git a/internal/db/postgres/restorers/blobs.go b/internal/db/postgres/restorers/blobs.go index 0fd12a18..1436d844 100644 --- a/internal/db/postgres/restorers/blobs.go +++ b/internal/db/postgres/restorers/blobs.go @@ -159,6 +159,10 @@ func (td *BlobsRestorer) execute(ctx context.Context, tx pgx.Tx) error { return nil } +func (td *BlobsRestorer) GetEntry() *toc.Entry { + return td.Entry +} + func (td *BlobsRestorer) DebugInfo() string { return fmt.Sprintf("blobs %s", *td.Entry.Tag) } diff --git a/internal/db/postgres/restorers/restorer.go b/internal/db/postgres/restorers/restorer.go index fe6a7c09..2099c9d6 100644 --- a/internal/db/postgres/restorers/restorer.go +++ b/internal/db/postgres/restorers/restorer.go @@ -17,10 +17,12 @@ package restorers import ( "context" + "github.com/greenmaskio/greenmask/internal/db/postgres/toc" "github.com/jackc/pgx/v5" ) type RestoreTask interface { Execute(ctx context.Context, conn *pgx.Conn) error DebugInfo() string + GetEntry() *toc.Entry } diff --git a/internal/db/postgres/restorers/sequence.go b/internal/db/postgres/restorers/sequence.go index 0fc79e62..9a92f8d9 100644 --- a/internal/db/postgres/restorers/sequence.go +++ b/internal/db/postgres/restorers/sequence.go @@ -34,6 +34,10 @@ func NewSequenceRestorer(entry *toc.Entry) *SequenceRestorer { } } +func (td *SequenceRestorer) GetEntry() *toc.Entry { + return td.Entry +} + func (td *SequenceRestorer) Execute(ctx context.Context, conn *pgx.Conn) error { tx, err := conn.Begin(ctx) if err != nil { diff --git a/internal/db/postgres/restorers/table.go b/internal/db/postgres/restorers/table.go index 1594f7e8..e8ab4171 100644 --- a/internal/db/postgres/restorers/table.go +++ b/internal/db/postgres/restorers/table.go @@ -46,6 +46,10 @@ func NewTableRestorer(entry *toc.Entry, st storages.Storager, exitOnError bool) } } +func (td *TableRestorer) GetEntry() *toc.Entry { + return td.Entry +} + func (td *TableRestorer) Execute(ctx context.Context, conn *pgx.Conn) error { // TODO: Add tests diff --git a/internal/db/postgres/restorers/table_insert_format.go b/internal/db/postgres/restorers/table_insert_format.go index ab2cc88d..5b63ff88 100644 --- a/internal/db/postgres/restorers/table_insert_format.go +++ b/internal/db/postgres/restorers/table_insert_format.go @@ -82,6 +82,10 @@ func NewTableRestorerInsertFormat( } } +func (td *TableRestorerInsertFormat) GetEntry() *toc.Entry { + return td.Entry +} + func (td *TableRestorerInsertFormat) Execute(ctx context.Context, conn *pgx.Conn) error { if td.Entry.FileName == nil {