mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-20 04:36:09 +08:00

* Enable blank issue * chore(README.md): update docs (temporally) * Update FUNDING.yml * chore: purge README.md * chore: change module name to OpenListTeam/OpenList * fix: fix link errors * chore: remove v3 in module name * fix: resolve some conficts * fix: resolve conficts * docs: update with latest file --------- Co-authored-by: ShenLin <773933146@qq.com> Co-authored-by: Hantong Chen <cxwdyx620@gmail.com> Co-authored-by: joshua <i@joshua.su> Co-authored-by: Hantong Chen <70561268+cxw620@users.noreply.github.com>
40 lines
943 B
Go
40 lines
943 B
Go
package fs
|
|
|
|
import (
|
|
"context"
|
|
stdpath "path"
|
|
"time"
|
|
|
|
"github.com/OpenListTeam/OpenList/internal/model"
|
|
"github.com/OpenListTeam/OpenList/internal/op"
|
|
"github.com/OpenListTeam/OpenList/pkg/utils"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func get(ctx context.Context, path string) (model.Obj, error) {
|
|
path = utils.FixAndCleanPath(path)
|
|
// maybe a virtual file
|
|
if path != "/" {
|
|
virtualFiles := op.GetStorageVirtualFilesByPath(stdpath.Dir(path))
|
|
for _, f := range virtualFiles {
|
|
if f.GetName() == stdpath.Base(path) {
|
|
return f, nil
|
|
}
|
|
}
|
|
}
|
|
storage, actualPath, err := op.GetStorageAndActualPath(path)
|
|
if err != nil {
|
|
// if there are no storage prefix with path, maybe root folder
|
|
if path == "/" {
|
|
return &model.Object{
|
|
Name: "root",
|
|
Size: 0,
|
|
Modified: time.Time{},
|
|
IsFolder: true,
|
|
}, nil
|
|
}
|
|
return nil, errors.WithMessage(err, "failed get storage")
|
|
}
|
|
return op.Get(ctx, storage, actualPath)
|
|
}
|