mirror of
https://github.com/AlistGo/alist.git
synced 2025-11-25 03:15:10 +08:00
* refactor:separate the setting method from the db package to the op package and add the cache
* refactor:separate the meta method from the db package to the op package
* fix:setting not load database data
* refactor:separate the user method from the db package to the op package
* refactor:remove user JoinPath error
* fix:op package user cache
* refactor:fs package list method
* fix:tile virtual paths (close #2743)
* Revert "refactor:remove user JoinPath error"
This reverts commit 4e20daaf9e.
* clean path directly may lead to unknown behavior
* fix: The path of the meta passed in must be prefix of reqPath
* chore: rename all virtualPath to mountPath
* fix: `getStoragesByPath` and `GetStorageVirtualFilesByPath`
is_sub_path:
/a/b isn't subpath of /a/bc
* fix: don't save setting if hook error
Co-authored-by: Noah Hsu <i@nn.ci>
26 lines
848 B
Go
26 lines
848 B
Go
package op
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/alist-org/alist/v3/internal/driver"
|
|
"github.com/alist-org/alist/v3/pkg/utils"
|
|
"github.com/pkg/errors"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// GetStorageAndActualPath Get the corresponding storage and actual path
|
|
// for path: remove the mount path prefix and join the actual root folder if exists
|
|
func GetStorageAndActualPath(rawPath string) (storage driver.Driver, actualPath string, err error) {
|
|
rawPath = utils.FixAndCleanPath(rawPath)
|
|
storage = GetBalancedStorage(rawPath)
|
|
if storage == nil {
|
|
err = errors.Errorf("can't find storage with rawPath: %s", rawPath)
|
|
return
|
|
}
|
|
log.Debugln("use storage: ", storage.GetStorage().MountPath)
|
|
mountPath := utils.GetActualMountPath(storage.GetStorage().MountPath)
|
|
actualPath = utils.FixAndCleanPath(strings.TrimPrefix(rawPath, mountPath))
|
|
return
|
|
}
|