修复本地模式下路由问题

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) zap.ReplaceGlobals(logger)
dir, _ := os.Getwd() dir, _ := os.Getwd()
path = dir path = dir
zap.L().Info("exec workdir", zap.String("path", path))
flag.StringVar(&org, "org", org, "org") flag.StringVar(&org, "org", org, "org")
flag.StringVar(&repo, "repo", repo, "repo") flag.StringVar(&repo, "repo", repo, "repo")
flag.StringVar(&domain, "domain", domain, "domain") flag.StringVar(&domain, "domain", domain, "domain")
@@ -48,7 +47,7 @@ func init() {
} }
func main() { 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() { if stat, err := os.Stat(path); err != nil || !stat.IsDir() {
zap.L().Fatal("path is not a directory", zap.String("path", path)) zap.L().Fatal("path is not a directory", zap.String("path", path))
} }

View File

@@ -10,6 +10,7 @@ import (
"net/http/httptest" "net/http/httptest"
"os" "os"
"path/filepath" "path/filepath"
"slices"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -42,7 +43,14 @@ func (l *LocalProvider) Close() error {
return nil 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{ return &core.Metadata{
ID: "localhost", ID: "localhost",
LastModified: time.Now(), LastModified: time.Now(),