Get T5 products from the hub's catalogs
CI / build (push) Successful in 25s

The proxy keeps the person's library in a cache folder (hub-products in its data folder), one pack per
product, served like any other pack: the hub says which revision to load and which catalogs host it, each file
comes from a catalog and is checked against the hub's sha256 (files are kept by hash, so a new revision only
downloads what changed), and adult files are fetched with the hub's access token. Products someone wears in a
room that aren't here yet are fetched too, and put on them when they arrive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
dhkatzandClaude Opus 5.5 committed 2026-10-29 18:56:26 -07:00
1 parent 93fa2f5d90
commit c281fb572c
6 files changed
+579 -3

No files matched your search

+11 -1
View File
@@ -33,6 +33,7 @@ import (
"time"
"git.t5de.dev/t5de/t5de-proxy/internal/buildinfo"
"git.t5de.dev/t5de/t5de-proxy/internal/fetch"
"git.t5de.dev/t5de/t5de-proxy/internal/hub"
"git.t5de.dev/t5de/t5de-proxy/internal/parent"
"git.t5de.dev/t5de/t5de-proxy/internal/products"
@@ -125,7 +126,12 @@ func run(logger *log.Logger, listen, ready string, parentPID int, trace bool, pa
}()
}
handler := &proxy.Server{Token: token, Log: logger, Trace: trace}
prods, err := products.New(packs, data, logger.Printf)
// Products from the hub's catalogs are kept as packs in their own folder, served like the others.
hubProducts := filepath.Join(data, "hub-products")
if err := os.MkdirAll(hubProducts, 0o755); err != nil {
logger.Printf("hub products: %v", err)
}
prods, err := products.New(append(packs, hubProducts), data, logger.Printf)
if err != nil {
logger.Printf("community products are off: %v", err)
} else {
@@ -134,10 +140,14 @@ func run(logger *log.Logger, listen, ready string, parentPID int, trace bool, pa
}
if saved, err := hub.Load(filepath.Join(data, "hub.json")); err == nil {
client := hub.New(filepath.Join(data, "hub.json"), saved, logger)
fetcher := fetch.New(client, hubProducts, logger.Printf)
if prods != nil {
prods.Observer = client
client.OnChat = prods.Others
fetcher.OnReady = prods.Ready
prods.Want = fetcher.Want
}
client.OnLibrary = func() { fetcher.SyncLibrary(context.Background()) }
go client.Run(context.Background())
} else if !errors.Is(err, hub.ErrSignedOut) {
logger.Printf("hub: %v", err)