修复本地模式下路由问题

This commit is contained in:
dragon
2026-01-27 17:32:36 +08:00
parent 1c52ee05b6
commit cd573483ea
2 changed files with 10 additions and 3 deletions

View File

@@ -38,7 +38,6 @@ func init() {
zap.ReplaceGlobals(logger)
dir, _ := os.Getwd()
path = dir
zap.L().Info("exec workdir", zap.String("path", path))
flag.StringVar(&org, "org", org, "org")
flag.StringVar(&repo, "repo", repo, "repo")
flag.StringVar(&domain, "domain", domain, "domain")
@@ -48,7 +47,7 @@ func init() {
}
func main() {
fmt.Printf("请访问 http://%s%s/", repo, port)
fmt.Printf("请访问 http://%s%s/ ,本地路径: %s", repo, port, path)
if stat, err := os.Stat(path); err != nil || !stat.IsDir() {
zap.L().Fatal("path is not a directory", zap.String("path", path))
}

View File

@@ -10,6 +10,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
"time"
@@ -42,7 +43,14 @@ func (l *LocalProvider) Close() error {
return nil
}
func (l *LocalProvider) Meta(_ context.Context, _, _ string) (*core.Metadata, error) {
func (l *LocalProvider) Meta(_ context.Context, owner, repo string) (*core.Metadata, error) {
if _, ok := l.graph[owner]; !ok {
return nil, os.ErrNotExist
}
if !slices.Contains(l.graph[owner], repo) {
return nil, os.ErrNotExist
}
return &core.Metadata{
ID: "localhost",
LastModified: time.Now(),