mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Anonymise marker titles (#3542)
This commit is contained in:
parent
e2b52a4bf6
commit
ac67d640db
2 changed files with 58 additions and 0 deletions
|
|
@ -51,6 +51,7 @@ func (db *Anonymiser) Anonymise(ctx context.Context) error {
|
||||||
func() error { return db.anonymiseFiles(ctx) },
|
func() error { return db.anonymiseFiles(ctx) },
|
||||||
func() error { return db.anonymiseFingerprints(ctx) },
|
func() error { return db.anonymiseFingerprints(ctx) },
|
||||||
func() error { return db.anonymiseScenes(ctx) },
|
func() error { return db.anonymiseScenes(ctx) },
|
||||||
|
func() error { return db.anonymiseMarkers(ctx) },
|
||||||
func() error { return db.anonymiseImages(ctx) },
|
func() error { return db.anonymiseImages(ctx) },
|
||||||
func() error { return db.anonymiseGalleries(ctx) },
|
func() error { return db.anonymiseGalleries(ctx) },
|
||||||
func() error { return db.anonymisePerformers(ctx) },
|
func() error { return db.anonymisePerformers(ctx) },
|
||||||
|
|
@ -295,6 +296,58 @@ func (db *Anonymiser) anonymiseScenes(ctx context.Context) error {
|
||||||
return nil
|
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 {
|
func (db *Anonymiser) anonymiseImages(ctx context.Context) error {
|
||||||
logger.Infof("Anonymising images")
|
logger.Infof("Anonymising images")
|
||||||
table := imageTableMgr.table
|
table := imageTableMgr.table
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,11 @@ var (
|
||||||
idColumn: goqu.T(sceneTable).Col(idColumn),
|
idColumn: goqu.T(sceneTable).Col(idColumn),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sceneMarkerTableMgr = &table{
|
||||||
|
table: goqu.T(sceneMarkerTable),
|
||||||
|
idColumn: goqu.T(sceneMarkerTable).Col(idColumn),
|
||||||
|
}
|
||||||
|
|
||||||
scenesFilesTableMgr = &relatedFilesTable{
|
scenesFilesTableMgr = &relatedFilesTable{
|
||||||
table: table{
|
table: table{
|
||||||
table: scenesFilesJoinTable,
|
table: scenesFilesJoinTable,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue