mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-23 03:55:00 +00:00
Fix: Model Gallery Downloads (#835)
This commit is contained in:
parent
688f150463
commit
5ce0f216cf
2 changed files with 5 additions and 4 deletions
|
@ -18,5 +18,5 @@ func inTrustedRoot(path string, trustedRoot string) error {
|
||||||
// VerifyPath verifies that path is based in basePath.
|
// VerifyPath verifies that path is based in basePath.
|
||||||
func VerifyPath(path, basePath string) error {
|
func VerifyPath(path, basePath string) error {
|
||||||
c := filepath.Clean(filepath.Join(basePath, path))
|
c := filepath.Clean(filepath.Join(basePath, path))
|
||||||
return inTrustedRoot(c, basePath)
|
return inTrustedRoot(c, filepath.Clean(basePath))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@ package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ func GetURI(url string, f func(url string, i []byte) error) error {
|
||||||
if strings.HasPrefix(url, "file://") {
|
if strings.HasPrefix(url, "file://") {
|
||||||
rawURL := strings.TrimPrefix(url, "file://")
|
rawURL := strings.TrimPrefix(url, "file://")
|
||||||
// Read the response body
|
// Read the response body
|
||||||
body, err := ioutil.ReadFile(rawURL)
|
body, err := os.ReadFile(rawURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -49,7 +50,7 @@ func GetURI(url string, f func(url string, i []byte) error) error {
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Read the response body
|
// Read the response body
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := io.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue