feat(upload): extract upload subsystem + move sweep to scanner ticker (B16)
- internal/upload owns chunked-upload domain logic (fingerprint resume, part tmp+rename, assemble, session sweep) and the shared UniquePath helper used by both single-file and chunked completion paths - handlers/uploads.go is now HTTP-only: bind params, call upload.U, map sentinel errors to the unchanged status/code/message contract - B16: session sweep moved out of the UploadInit request path onto the scanner ticker via a Sweeper hook (upload.U satisfies it) - unit tests for the package without PG/Redis; contract pinned by the existing handler integration tests (all green)
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"booklib/internal/scanner"
|
||||
"booklib/internal/seed"
|
||||
"booklib/internal/store"
|
||||
"booklib/internal/upload"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -39,11 +40,12 @@ func main() {
|
||||
log.Fatalf("seed: %v", err)
|
||||
}
|
||||
rdb := redispkg.New(cfg.RedisURL)
|
||||
sc := scanner.New(st, cfg, rdb)
|
||||
up := upload.New(cfg.BooksDir, cfg.UploadMaxMB)
|
||||
sc := scanner.New(st, cfg, rdb, up) // B16: sweep rides the scan ticker
|
||||
go sc.Run(ctx)
|
||||
|
||||
serveErr := make(chan error, 1)
|
||||
srv := &http.Server{Addr: cfg.Addr, Handler: api.NewRouter(cfg, st, rdb, sc),
|
||||
srv := &http.Server{Addr: cfg.Addr, Handler: api.NewRouter(cfg, st, rdb, sc, up),
|
||||
ReadHeaderTimeout: 10 * time.Second}
|
||||
go func() {
|
||||
log.Printf("listening on %s", cfg.Addr)
|
||||
|
||||
Reference in New Issue
Block a user