Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/strm/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Addition struct {
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
LocalModel bool `json:"localModel" default:"false" help:"enable local mode"`
LMRootPath string `json:"localModel_RootPath" required:"false" help:"root path prefix in local mode"`
}

var config = driver.Config{
Expand Down
25 changes: 14 additions & 11 deletions drivers/strm/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

stdpath "path"
"path/filepath"
"strings"

"github.com/OpenListTeam/OpenList/v4/internal/fs"
Expand Down Expand Up @@ -127,21 +128,23 @@ func (d *Strm) list(ctx context.Context, dst, sub string, args *fs.ListArgs) ([]
}

func (d *Strm) getLink(ctx context.Context, path string) string {
var encodePath string
var finalPath string
if d.EncodePath {
encodePath = utils.EncodePath(path, true)
finalPath = utils.EncodePath(path, true)
} else {
finalPath = path
}
if d.EnableSign {
signPath := sign.Sign(path)
if len(encodePath) > 0 {
path = fmt.Sprintf("%s?sign=%s", encodePath, signPath)
} else {
path = fmt.Sprintf("%s?sign=%s", path, signPath)
if d.LocalModel {
if d.LMRootPath != "" {
finalPath = filepath.Join(d.LMRootPath, finalPath)
}
return finalPath
}
if d.LocalModel {
return path
if d.EnableSign {
signPath := sign.Sign(path)
finalPath = fmt.Sprintf("%s?sign=%s", finalPath, signPath)
}

apiUrl := d.SiteUrl
if len(apiUrl) > 0 {
apiUrl = strings.TrimSuffix(apiUrl, "/")
Expand All @@ -151,5 +154,5 @@ func (d *Strm) getLink(ctx context.Context, path string) string {

return fmt.Sprintf("%s/d%s",
apiUrl,
path)
finalPath)
}