mirror of https://github.com/Xhofe/alist
fix(search): empty parent where update (close #2810)
parent
1cfd47a258
commit
6453ae0968
|
@ -68,9 +68,9 @@ func (d *Local) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
|
|||
}
|
||||
thumb := ""
|
||||
if d.Thumbnail && utils.GetFileType(f.Name()) == conf.IMAGE {
|
||||
thumb = common.GetApiUrl(nil) + stdpath.Join("/d", args.ReqPath, f.Name())
|
||||
thumb = common.GetApiUrl(nil) + stdpath.Join("/d", utils.GetFullPath(d.MountPath, fullPath), f.Name())
|
||||
thumb = utils.EncodePath(thumb, true)
|
||||
thumb += "?type=thumb&sign=" + sign.Sign(stdpath.Join(args.ReqPath, f.Name()))
|
||||
thumb += "?type=thumb&sign=" + sign.Sign(stdpath.Join(utils.GetFullPath(d.MountPath, fullPath), f.Name()))
|
||||
}
|
||||
isFolder := f.IsDir() || isSymlinkDir(f, fullPath)
|
||||
var size int64
|
||||
|
|
|
@ -23,7 +23,7 @@ func list(ctx context.Context, path string, refresh ...bool) ([]model.Obj, error
|
|||
var _objs []model.Obj
|
||||
if storage != nil {
|
||||
_objs, err = op.List(ctx, storage, actualPath, model.ListArgs{
|
||||
ReqPath: path,
|
||||
//ReqPath: path,
|
||||
}, refresh...)
|
||||
if err != nil {
|
||||
log.Errorf("%+v", err)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
type ListArgs struct {
|
||||
ReqPath string
|
||||
//ReqPath string
|
||||
}
|
||||
|
||||
type LinkArgs struct {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/maruel/natural"
|
||||
)
|
||||
|
||||
type UnwrapObj interface {
|
||||
type ObjUnwrap interface {
|
||||
Unwrap() Obj
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,6 @@ func ExtractFolder(objs []Obj, extractFolder string) {
|
|||
})
|
||||
}
|
||||
|
||||
// Wrap
|
||||
func WrapObjName(objs Obj) Obj {
|
||||
return &ObjWrapName{Obj: objs}
|
||||
}
|
||||
|
@ -110,8 +109,8 @@ func WrapObjsName(objs []Obj) {
|
|||
}
|
||||
}
|
||||
|
||||
func UnwrapObjs(obj Obj) Obj {
|
||||
if unwrap, ok := obj.(UnwrapObj); ok {
|
||||
func UnwrapObj(obj Obj) Obj {
|
||||
if unwrap, ok := obj.(ObjUnwrap); ok {
|
||||
obj = unwrap.Unwrap()
|
||||
}
|
||||
return obj
|
||||
|
@ -121,7 +120,7 @@ func GetThumb(obj Obj) (thumb string, ok bool) {
|
|||
if obj, ok := obj.(Thumb); ok {
|
||||
return obj.Thumb(), true
|
||||
}
|
||||
if unwrap, ok := obj.(UnwrapObj); ok {
|
||||
if unwrap, ok := obj.(ObjUnwrap); ok {
|
||||
return GetThumb(unwrap.Unwrap())
|
||||
}
|
||||
return thumb, false
|
||||
|
@ -131,7 +130,7 @@ func GetUrl(obj Obj) (url string, ok bool) {
|
|||
if obj, ok := obj.(URL); ok {
|
||||
return obj.URL(), true
|
||||
}
|
||||
if unwrap, ok := obj.(UnwrapObj); ok {
|
||||
if unwrap, ok := obj.(ObjUnwrap); ok {
|
||||
return GetUrl(unwrap.Unwrap())
|
||||
}
|
||||
return url, false
|
||||
|
|
|
@ -130,9 +130,9 @@ func List(ctx context.Context, storage driver.Driver, path string, args model.Li
|
|||
// call hooks
|
||||
go func(reqPath string, files []model.Obj) {
|
||||
for _, hook := range objsUpdateHooks {
|
||||
hook(args.ReqPath, files)
|
||||
hook(reqPath, files)
|
||||
}
|
||||
}(args.ReqPath, files)
|
||||
}(utils.GetFullPath(storage.GetStorage().MountPath, path), files)
|
||||
|
||||
// sort objs
|
||||
if storage.Config().LocalSort {
|
||||
|
@ -218,7 +218,7 @@ func GetUnwrap(ctx context.Context, storage driver.Driver, path string) (model.O
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.UnwrapObjs(obj), err
|
||||
return model.UnwrapObj(obj), err
|
||||
}
|
||||
|
||||
var linkCache = cache.NewMemCache(cache.WithShards[*model.Link](16))
|
||||
|
@ -338,7 +338,7 @@ func Move(ctx context.Context, storage driver.Driver, srcPath, dstDirPath string
|
|||
if err != nil {
|
||||
return errors.WithMessage(err, "failed to get src object")
|
||||
}
|
||||
srcObj := model.UnwrapObjs(srcRawObj)
|
||||
srcObj := model.UnwrapObj(srcRawObj)
|
||||
dstDir, err := GetUnwrap(ctx, storage, dstDirPath)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed to get dst dir")
|
||||
|
@ -380,7 +380,7 @@ func Rename(ctx context.Context, storage driver.Driver, srcPath, dstName string,
|
|||
if err != nil {
|
||||
return errors.WithMessage(err, "failed to get src object")
|
||||
}
|
||||
srcObj := model.UnwrapObjs(srcRawObj)
|
||||
srcObj := model.UnwrapObj(srcRawObj)
|
||||
srcDirPath := stdpath.Dir(srcPath)
|
||||
|
||||
switch s := storage.(type) {
|
||||
|
@ -460,7 +460,7 @@ func Remove(ctx context.Context, storage driver.Driver, path string) error {
|
|||
|
||||
switch s := storage.(type) {
|
||||
case driver.Remove:
|
||||
err = s.Remove(ctx, model.UnwrapObjs(rawObj))
|
||||
err = s.Remove(ctx, model.UnwrapObj(rawObj))
|
||||
if err == nil {
|
||||
delCacheObj(storage, dirPath, rawObj)
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ func IsBalance(str string) bool {
|
|||
}
|
||||
|
||||
// GetActualMountPath remove balance suffix
|
||||
func GetActualMountPath(virtualPath string) string {
|
||||
bIndex := strings.LastIndex(virtualPath, ".balance")
|
||||
func GetActualMountPath(mountPath string) string {
|
||||
bIndex := strings.LastIndex(mountPath, ".balance")
|
||||
if bIndex != -1 {
|
||||
virtualPath = virtualPath[:bIndex]
|
||||
mountPath = mountPath[:bIndex]
|
||||
}
|
||||
return virtualPath
|
||||
return mountPath
|
||||
}
|
||||
|
|
|
@ -80,3 +80,7 @@ func JoinBasePath(basePath, reqPath string) (string, error) {
|
|||
}
|
||||
return stdpath.Join(FixAndCleanPath(basePath), FixAndCleanPath(reqPath)), nil
|
||||
}
|
||||
|
||||
func GetFullPath(mountPath, path string) string {
|
||||
return stdpath.Join(GetActualMountPath(mountPath), path)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue