Anonymise marker titles (#3542)

This commit is contained in:
WithoutPants 2023-03-16 09:07:33 +11:00 committed by GitHub
parent e2b52a4bf6
commit ac67d640db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

View File

@ -51,6 +51,7 @@ func (db *Anonymiser) Anonymise(ctx context.Context) error {
func() error { return db.anonymiseFiles(ctx) },
func() error { return db.anonymiseFingerprints(ctx) },
func() error { return db.anonymiseScenes(ctx) },
func() error { return db.anonymiseMarkers(ctx) },
func() error { return db.anonymiseImages(ctx) },
func() error { return db.anonymiseGalleries(ctx) },
func() error { return db.anonymisePerformers(ctx) },
@ -295,6 +296,58 @@ func (db *Anonymiser) anonymiseScenes(ctx context.Context) error {
return nil
}
func (db *Anonymiser) anonymiseMarkers(ctx context.Context) error {
logger.Infof("Anonymising scene markers")
table := sceneMarkerTableMgr.table
lastID := 0
total := 0
const logEvery = 10000
for gotSome := true; gotSome; {
if err := txn.WithTxn(ctx, db, func(ctx context.Context) error {
query := dialect.From(table).Select(
table.Col(idColumn),
table.Col("title"),
).Where(table.Col(idColumn).Gt(lastID)).Limit(1000)
gotSome = false
const single = false
return queryFunc(ctx, query, single, func(rows *sqlx.Rows) error {
var (
id int
title string
)
if err := rows.Scan(
&id,
&title,
); err != nil {
return err
}
if err := db.anonymiseText(ctx, table, "title", title); err != nil {
return err
}
lastID = id
gotSome = true
total++
if total%logEvery == 0 {
logger.Infof("Anonymised %d scene markers", total)
}
return nil
})
}); err != nil {
return err
}
}
return nil
}
func (db *Anonymiser) anonymiseImages(ctx context.Context) error {
logger.Infof("Anonymising images")
table := imageTableMgr.table

View File

@ -112,6 +112,11 @@ var (
idColumn: goqu.T(sceneTable).Col(idColumn),
}
sceneMarkerTableMgr = &table{
table: goqu.T(sceneMarkerTable),
idColumn: goqu.T(sceneMarkerTable).Col(idColumn),
}
scenesFilesTableMgr = &relatedFilesTable{
table: table{
table: scenesFilesJoinTable,