coding tweaks in preparation for crafting "delete conference" code

This commit is contained in:
2026-02-19 23:24:49 -07:00
parent 831c6c5524
commit d2e6396ca7
8 changed files with 48 additions and 13 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ import (
"fmt"
"time"
"git.erbosoft.com/amy/amsterdam/config"
log "github.com/sirupsen/logrus"
)
@@ -150,7 +151,7 @@ func AmStoreAudit(rec *AuditRecord) {
// setupAuditWriter sets up the background audit writer.
func setupAuditWriter() func() {
auditWriteQueue = make(chan *AuditRecord, 16)
auditWriteQueue = make(chan *AuditRecord, config.GlobalConfig.Tuning.Queues.AuditWrites)
doneChan := make(chan bool)
go auditWriter(auditWriteQueue, doneChan)
return func() {
+2 -1
View File
@@ -20,6 +20,7 @@ import (
"sync"
"time"
"git.erbosoft.com/amy/amsterdam/config"
log "github.com/sirupsen/logrus"
)
@@ -140,7 +141,7 @@ var banSweeperInput chan *sweepentry
// setupIPBanSweep sets up the IP ban sweeper routine, and returns a function that tears it down.
func setupIPBanSweep() func() {
banSweeperReset = make(chan bool)
banSweeperInput = make(chan *sweepentry, 32)
banSweeperInput = make(chan *sweepentry, config.GlobalConfig.Tuning.Queues.IPBans)
done := make(chan bool)
ended := make(chan bool)
go banSweeper(done, ended, banSweeperReset, banSweeperInput)
+13 -7
View File
@@ -427,6 +427,18 @@ func backgroundPurgeTopic(ctx context.Context, topicid int32) error {
return nil
}
// eraseTopicRecords erases the high-level records for a topic from the database.
func eraseTopicRecords(ctx context.Context, tx *sqlx.Tx, topicid int32) error {
_, err := tx.ExecContext(ctx, "DELETE FROM topics WHERE topicid = ?", topicid)
if err == nil {
_, err = tx.ExecContext(ctx, "DELETE FROM topicsettings WHERE topicid = ?", topicid)
if err == nil {
_, err = tx.ExecContext(ctx, "DELETE FROM topicbozo WHERE topicid = ?", topicid)
}
}
return err
}
// Delete deletes this topic.
func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *util.WorkerPool) error {
var ar *AuditRecord = nil
@@ -446,13 +458,7 @@ func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *
return err
}
_, err = tx.ExecContext(ctx, "DELETE FROM topics WHERE topicid = ?", t.TopicId)
if err == nil {
_, err = tx.ExecContext(ctx, "DELETE FROM topicsettings WHERE topicid = ?", t.TopicId)
if err == nil {
_, err = tx.ExecContext(ctx, "DELETE FROM topicbozo WHERE topicid = ?", t.TopicId)
}
}
err = eraseTopicRecords(ctx, tx, t.TopicId)
if err != nil {
return err
}