fix cache issue

pull/77/head
kun 2019-07-05 15:52:41 +08:00
parent 2c027c90d6
commit d801eee16f
1 changed files with 21 additions and 10 deletions

View File

@ -107,19 +107,30 @@ func NewProxy(cache string) http.Handler {
} }
switch suf { switch suf {
case "/@v/list": case "/@v/list":
if info, err := repo.Versions(""); err != nil { modPath := strings.Trim(strings.TrimSuffix(r.URL.Path, "/@v/list"), "/")
ReturnInternalServerError(w, err) modPath, err := module.DecodePath(modPath)
} else { if err != nil {
data := strings.Join(info, "\n")
ReturnSuccess(w, []byte(data))
}
case "/@latest":
modLatestInfo, err := repo.Latest()
if err != nil {
ReturnInternalServerError(w, err) ReturnInternalServerError(w, err)
return return
} }
ReturnJsonData(w, modLatestInfo)
modload.LoadBuildList()
mods := modload.ListModules([]string{modPath + "@latest"}, false, true)
data := []byte(strings.Join(mods[0].Versions, "\n") + "\n")
if len(data) == 1 {
data = nil
}
w.Write(data)
return
case "/@latest":
rev, err := repo.Stat("latest")
if err != nil {
errLogger.Printf("latest failed: %v", err)
return
}
ReturnJsonData(w, rev)
return
} }
return return
} }