feat(recovery): retry saved Googlevideo scenarios first

Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
ZeusinaandGPT-6 Bot committed 2026-10-09 23:10:25 +03:00
1 parent 6220eb0b31
commit aaa8f751c6
7 files changed
+345 -7

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
package main
import (
"bytes"
"context"
"database/sql"
"errors"
"fmt"
"io"
"os"
)
// Only complete, well-formed non-passing measurements permit scan fallback.
var errCandidateNonpass = errors.New("saved scenario did not pass both TLS protocols")
func revalidateGooglevideo(ctx context.Context, db *sql.DB, host string, stderr io.Writer, check cacheCheck) (string, []byte, error) {
rows, err := db.Query(`SELECT id FROM strategy_candidates WHERE strategy_group = 'googlevideo' ORDER BY id DESC`)
if err != nil {
return "", nil, err
}
var ids []int64
for rows.Next() {
var id int64
if err := rows.Scan(&id); err != nil {
rows.Close()
return "", nil, err
}
ids = append(ids, id)
}
err = rows.Err()
closeErr := rows.Close() // Release the store's single connection before candidate reads.
if err == nil {
err = closeErr
}
if err != nil {
return "", nil, err
}
for _, id := range ids {
if err := ctx.Err(); err != nil {
return "", nil, err
}
c, err := readStrategyCandidate(db, id)
if err != nil {
return "", nil, err
}
if !c.Qualified {
continue
}
artifact, err := os.CreateTemp("", "blockcheckw-recover-*.txt")
if err != nil {
return "", nil, err
}
path := artifact.Name()
if err := artifact.Close(); err != nil {
return "", nil, err
}
fmt.Fprintln(stderr, "Rechecking saved candidate:", id, "exact endpoint:", host, "Blockcheck artifacts:", path)
var raw bytes.Buffer
err = check(ctx, "blockcheckw", path, c.Args, host, &raw, &raw)
if e := os.WriteFile(path+".stdout", raw.Bytes(), 0600); e != nil {
err = e
}
if err != nil {
return "", nil, err
}
if err := ctx.Err(); err != nil {
return "", nil, err
}
report, err := os.ReadFile(path + ".combined.json")
if err != nil {
return "", nil, err
}
_, err = selectBlockcheckEvidence(bytes.NewReader(report), c.Args, "googlevideo", host, true)
if errors.Is(err, errCandidateNonpass) {
continue
}
return c.Args, report, err
}
return "", nil, ctx.Err()
}