mirror of https://github.com/stashapp/stash.git
Anonymise marker titles (#3542)
This commit is contained in:
parent
e2b52a4bf6
commit
ac67d640db
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue