diff --git a/drivers/strm/meta.go b/drivers/strm/meta.go index 2116810fb..a0aad58a1 100644 --- a/drivers/strm/meta.go +++ b/drivers/strm/meta.go @@ -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{ diff --git a/drivers/strm/util.go b/drivers/strm/util.go index 4b77eec78..acc9a7204 100644 --- a/drivers/strm/util.go +++ b/drivers/strm/util.go @@ -5,6 +5,7 @@ import ( "fmt" stdpath "path" + "path/filepath" "strings" "github.com/OpenListTeam/OpenList/v4/internal/fs" @@ -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, "/") @@ -151,5 +154,5 @@ func (d *Strm) getLink(ctx context.Context, path string) string { return fmt.Sprintf("%s/d%s", apiUrl, - path) + finalPath) }