mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Anonymise marker titles (#3542)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user