fix latest fetch

pull/21/head
kun 2018-12-25 17:47:06 +08:00
parent 18c8979b4c
commit 3ba85be18d
1 changed files with 15 additions and 4 deletions

View File

@ -2,15 +2,16 @@ package proxy
import ( import (
"fmt" "fmt"
"github.com/goproxyio/goproxy/pkg/modfetch"
"github.com/goproxyio/goproxy/pkg/modfetch/codehost"
"github.com/goproxyio/goproxy/pkg/module"
"log" "log"
"net/http" "net/http"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/goproxyio/goproxy/pkg/modfetch"
"github.com/goproxyio/goproxy/pkg/modfetch/codehost"
"github.com/goproxyio/goproxy/pkg/module"
) )
var cacheDir string var cacheDir string
@ -61,7 +62,17 @@ func NewProxy(cache string) http.Handler {
ReturnServerError(w, err) ReturnServerError(w, err)
return return
} }
if err := downloadMod(modPath, "latest"); err != nil { repo, err := modfetch.Lookup(modPath)
if err != nil {
errLogger.Printf("lookup failed: %v", err)
ReturnServerError(w, err)
return
}
rev, err := repo.Stat("latest")
if err != nil {
errLogger.Printf("latest failed: %v", err)
}
if err := downloadMod(modPath, rev.Version); err != nil {
errLogger.Printf("download get err %s", err) errLogger.Printf("download get err %s", err)
} }
} }