Implement thread pruning based on bumped_at

This commit is contained in:
Dominic Ferrando
2025-04-21 14:00:10 -04:00
parent 997d65707c
commit 80a0a5eb89
4 changed files with 88 additions and 14 deletions
+6 -4
View File
@@ -17,11 +17,13 @@ var (
var CooldownMutex sync.Mutex
// const POST_COOLDOWN = 15 * time.Second
const POST_COOLDOWN = 0 * time.Second
const POST_COOLDOWN = 15 * time.Second
// const THREAD_COOLDOWN = 2 * time.Minute
const THREAD_COOLDOWN = 0 * time.Minute
// const POST_COOLDOWN = 0 * time.Second
const THREAD_COOLDOWN = 2 * time.Minute
// const THREAD_COOLDOWN = 0 * time.Minute
func IsOnCooldown(ip string, m map[string]time.Time, duration time.Duration) bool {
CooldownMutex.Lock()
+1 -9
View File
@@ -13,13 +13,13 @@ import (
"strings"
"github.com/disintegration/imaging"
"github.com/dominicf2001/comfychan/internal/database"
)
// 10 MB memory limit
const FILE_MEM_LIMIT int64 = 10 << 20
const POST_IMG_FULL_PATH = "web/static/img/posts/full"
const POST_IMG_THUMB_PATH = "web/static/img/posts/thumb"
const MAX_THREAD_COUNT = 50
func EnrichPost(body string) string {
var b strings.Builder
@@ -105,14 +105,6 @@ func SavePostFile(file *multipart.File, filename string) error {
return nil
}
func SumUniquePostIps(posts []database.Post) int {
uniqueIpHashes := map[string]bool{}
for _, post := range posts {
uniqueIpHashes[post.IpHash] = true
}
return len(uniqueIpHashes)
}
type PostImageInfo struct {
Size int64
Height int