Fix path conversions
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ var (
|
|||||||
|
|
||||||
// GetPlatformFile returns the latest platform specific file identified by the given identifier.
|
// GetPlatformFile returns the latest platform specific file identified by the given identifier.
|
||||||
func GetPlatformFile(identifier string) (*File, error) {
|
func GetPlatformFile(identifier string) (*File, error) {
|
||||||
identifier = filepath.Join(fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH), identifier)
|
identifier = path.Join(fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH), identifier)
|
||||||
// From https://golang.org/pkg/runtime/#GOARCH
|
// From https://golang.org/pkg/runtime/#GOARCH
|
||||||
// GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
|
// GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
|
||||||
// GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
|
// GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
|
||||||
@@ -25,7 +26,7 @@ func GetPlatformFile(identifier string) (*File, error) {
|
|||||||
|
|
||||||
// GetFile returns the latest generic file identified by the given identifier.
|
// GetFile returns the latest generic file identified by the given identifier.
|
||||||
func GetFile(identifier string) (*File, error) {
|
func GetFile(identifier string) (*File, error) {
|
||||||
identifier = filepath.Join("all", identifier)
|
identifier = path.Join("all", identifier)
|
||||||
return loadOrFetchFile(identifier)
|
return loadOrFetchFile(identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Safing/portbase/log"
|
"github.com/Safing/portbase/log"
|
||||||
@@ -29,14 +28,14 @@ func LoadLatest() error {
|
|||||||
prefix := "all"
|
prefix := "all"
|
||||||
new, err1 := ScanForLatest(filepath.Join(updateStoragePath, prefix), false)
|
new, err1 := ScanForLatest(filepath.Join(updateStoragePath, prefix), false)
|
||||||
for key, val := range new {
|
for key, val := range new {
|
||||||
newLocalUpdates[filepath.Join(prefix, key)] = val
|
newLocalUpdates[filepath.ToSlash(filepath.Join(prefix, key))] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// os_platform
|
// os_platform
|
||||||
prefix = fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
|
prefix = fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
|
||||||
new, err2 := ScanForLatest(filepath.Join(updateStoragePath, prefix), false)
|
new, err2 := ScanForLatest(filepath.Join(updateStoragePath, prefix), false)
|
||||||
for key, val := range new {
|
for key, val := range new {
|
||||||
newLocalUpdates[filepath.Join(prefix, key)] = val
|
newLocalUpdates[filepath.ToSlash(filepath.Join(prefix, key))] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
if err1 != nil && err2 != nil {
|
if err1 != nil && err2 != nil {
|
||||||
@@ -82,7 +81,11 @@ func ScanForLatest(baseDir string, hardFail bool) (latest map[string]string, las
|
|||||||
added++
|
added++
|
||||||
}
|
}
|
||||||
|
|
||||||
relativePath := strings.TrimLeft(strings.TrimPrefix(path, baseDir), "/")
|
relativePath, err := filepath.Rel(baseDir, path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
relativePath = filepath.ToSlash(relativePath)
|
||||||
identifierPath, version, ok := GetIdentifierAndVersion(relativePath)
|
identifierPath, version, ok := GetIdentifierAndVersion(relativePath)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user