gotosocial/internal/trans/exporter.go

46 lines
1.3 KiB
Go
Raw Normal View History

2021-09-06 18:52:25 +02:00
/*
GoToSocial
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package trans
import (
"context"
2021-09-07 11:43:47 +02:00
"github.com/sirupsen/logrus"
2021-09-06 18:52:25 +02:00
"github.com/superseriousbusiness/gotosocial/internal/db"
)
2021-09-08 12:25:14 +02:00
// Exporter wraps functionality for exporting entries from the database to a file.
2021-09-06 18:52:25 +02:00
type Exporter interface {
ExportMinimal(ctx context.Context, path string) error
}
type exporter struct {
2021-09-07 16:29:43 +02:00
db db.DB
log *logrus.Logger
writtenIDs map[string]bool
2021-09-06 18:52:25 +02:00
}
2021-09-08 12:25:14 +02:00
// NewExporter returns a new Exporter that will use the given db and logger.
2021-09-07 11:43:47 +02:00
func NewExporter(db db.DB, log *logrus.Logger) Exporter {
2021-09-06 18:52:25 +02:00
return &exporter{
2021-09-07 16:29:43 +02:00
db: db,
log: log,
writtenIDs: make(map[string]bool),
2021-09-06 18:52:25 +02:00
}
}