fix: temporarily disable tarballs caching to prevent yarn error
This commit is contained in:
parent
588ec835df
commit
2346dbaf87
@ -5,7 +5,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
|
||||||
|
|
||||||
if res.Header.Get("Content-Encoding") == "gzip" {
|
if res.Header.Get("Content-Encoding") == "gzip" {
|
||||||
zr, err := gzip.NewReader(res.Body)
|
zr, err := gzip.NewReader(res.Body)
|
||||||
@ -47,14 +45,17 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
|
|||||||
res.Body = zr
|
res.Body = zr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: avoid calling MustCompile every time
|
pkg = string(body)
|
||||||
// find "dist": "https?://.*/ and replace to "dist": "{localurl}/
|
|
||||||
pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`)
|
// // TODO: avoid calling MustCompile every time
|
||||||
|
// // find "dist": "https?://.*/ and replace to "dist": "{localurl}/
|
||||||
|
// pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`)
|
||||||
|
|
||||||
// save to redis
|
// save to redis
|
||||||
err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)
|
err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user