3 files changed,
2 insertions(+),
47 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-17 15:19:59 +0200
Authored at:
2026-03-17 15:10:01 +0200
Change ID:
uyntusqqkxzultnwutxtvvlyupnnuwyt
Parent:
a41a1ac
M
internal/cli/serve.go
路路路 42 42 mirrorer := mirror.NewWorker(c.cfg) 43 43 go func() { 44 44 slog.Info("starting mirroring worker") 45 - mirrorer.Start(context.TODO()) 45 + mirrorer.Start(ctx) 46 46 }() 47 47 } 48 48 路路路 52 52 sig := <-sigChan 53 53 slog.Info("received signal, starting graceful shutdown", "signal", sig) 54 54 55 - if err := httpServer.Shutdown(context.TODO()); err != nil { 55 + if err := httpServer.Shutdown(ctx); err != nil { 56 56 slog.Error("HTTP server shutdown error", "err", err) 57 57 } else { 58 58 slog.Info("HTTP server shutdown complete")
M
internal/git/paths.go
路路路 18 18 } 19 19 return path, err 20 20 } 21 - 22 -// topLevelEntry returns the top-level entry name under base for a given path. 23 -// e.g. base="lua", path="lua/plugins/foo.lua" -> "plugins" 24 -// e.g. base="", path="README.md" -> "README.md" 25 -// returns "" if path is not under base. 26 -func topLevelEntry(fullPath, base string) string { 27 - if base != "" && base != "." { 28 - if !strings.HasPrefix(fullPath, base+"/") { 29 - return "" 30 - } 31 - fullPath = fullPath[len(base)+1:] 32 - } 33 - if before, _, ok := strings.Cut(fullPath, "/"); ok { 34 - return before 35 - } 36 - return fullPath 37 -}
M
internal/handlers/repo.go
路路路 1 1 package handlers 2 2 3 3 import ( 4 - "bytes" 5 4 "errors" 6 5 "fmt" 7 6 "html/template" 8 - "io" 9 7 "log/slog" 10 8 "net/http" 11 9 "os" 路路路 367 365 Tags: tags, 368 366 Branches: branches, 369 367 })) 370 -} 371 - 372 -func countLines(r io.Reader) (int, error) { 373 - buf := make([]byte, 32*1024) 374 - bufLen := 0 375 - count := 0 376 - nl := []byte{'\n'} 377 - 378 - for { 379 - c, err := r.Read(buf) 380 - if c > 0 { 381 - bufLen += c 382 - } 383 - count += bytes.Count(buf[:c], nl) 384 - 385 - switch { 386 - case err == io.EOF: 387 - // handle last line not having a newline at the end 388 - if bufLen >= 1 && buf[(bufLen-1)%(32*1024)] != '\n' { 389 - count++ 390 - } 391 - return count, nil 392 - case err != nil: 393 - return 0, err 394 - } 395 - } 396 368 } 397 369 398 370 type repoList struct {