mirror of https://github.com/Xhofe/alist
parent
d94cf72da2
commit
83644dab85
|
@ -5,6 +5,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
//type BaseResp struct {
|
||||
|
@ -39,7 +40,7 @@ func (f File) GetSize() int64 {
|
|||
}
|
||||
|
||||
func (f File) GetName() string {
|
||||
return f.FileName
|
||||
return utils.MappingName(f.FileName)
|
||||
}
|
||||
|
||||
func (f File) ModTime() time.Time {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
// 居然有四种返回方式
|
||||
|
@ -134,7 +136,7 @@ type Cloud189File struct {
|
|||
}
|
||||
|
||||
func (c *Cloud189File) GetSize() int64 { return c.Size }
|
||||
func (c *Cloud189File) GetName() string { return c.Name }
|
||||
func (c *Cloud189File) GetName() string { return utils.MappingName(c.Name) }
|
||||
func (c *Cloud189File) ModTime() time.Time {
|
||||
if c.parseTime == nil {
|
||||
c.parseTime = MustParseTime(c.LastOpTime)
|
||||
|
@ -166,7 +168,7 @@ type Cloud189Folder struct {
|
|||
}
|
||||
|
||||
func (c *Cloud189Folder) GetSize() int64 { return 0 }
|
||||
func (c *Cloud189Folder) GetName() string { return c.Name }
|
||||
func (c *Cloud189Folder) GetName() string { return utils.MappingName(c.Name) }
|
||||
func (c *Cloud189Folder) ModTime() time.Time {
|
||||
if c.parseTime == nil {
|
||||
c.parseTime = MustParseTime(c.LastOpTime)
|
||||
|
|
|
@ -3,6 +3,8 @@ package baiduphoto
|
|||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
type TokenErrResp struct {
|
||||
|
@ -100,7 +102,7 @@ type (
|
|||
)
|
||||
|
||||
func (a *Album) GetSize() int64 { return 0 }
|
||||
func (a *Album) GetName() string { return fmt.Sprint(a.Title) }
|
||||
func (a *Album) GetName() string { return utils.MappingName(a.Title) }
|
||||
func (a *Album) ModTime() time.Time {
|
||||
if a.parseTime == nil {
|
||||
a.parseTime = toTime(a.Mtime)
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
type ErrResp struct {
|
||||
|
@ -147,7 +149,7 @@ type Files struct {
|
|||
}
|
||||
|
||||
func (c *Files) GetSize() int64 { size, _ := strconv.ParseInt(c.Size, 10, 64); return size }
|
||||
func (c *Files) GetName() string { return c.Name }
|
||||
func (c *Files) GetName() string { return utils.MappingName(c.Name) }
|
||||
func (c *Files) ModTime() time.Time { return c.ModifiedTime }
|
||||
func (c *Files) IsDir() bool { return c.Kind == FOLDER }
|
||||
func (c *Files) GetID() string { return c.ID }
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package model
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
type Object struct {
|
||||
ID string
|
||||
|
@ -12,7 +16,7 @@ type Object struct {
|
|||
}
|
||||
|
||||
func (o *Object) GetName() string {
|
||||
return o.Name
|
||||
return utils.MappingName(o.Name)
|
||||
}
|
||||
|
||||
func (o *Object) GetSize() int64 {
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Xhofe/go-cache"
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
|
@ -129,7 +128,7 @@ func Get(ctx context.Context, storage driver.Driver, path string) (model.Obj, er
|
|||
}
|
||||
for _, f := range files {
|
||||
// TODO maybe copy obj here
|
||||
if utils.MappingName(f.GetName(), conf.FilenameCharMap) == name {
|
||||
if f.GetName() == name {
|
||||
// use path as id, why don't set id in List function?
|
||||
// because files maybe cache, set id here can reduce memory usage
|
||||
if f.GetPath() == "" {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/search/searcher"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -54,7 +53,7 @@ func Index(ctx context.Context, parent string, obj model.Obj) error {
|
|||
}
|
||||
return instance.Index(ctx, model.SearchNode{
|
||||
Parent: parent,
|
||||
Name: utils.MappingName(obj.GetName(), conf.FilenameCharMap),
|
||||
Name: obj.GetName(),
|
||||
IsDir: obj.IsDir(),
|
||||
Size: obj.GetSize(),
|
||||
})
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package utils
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
func MappingName(name string, m map[string]string) string {
|
||||
for k, v := range m {
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
)
|
||||
|
||||
func MappingName(name string) string {
|
||||
for k, v := range conf.FilenameCharMap {
|
||||
name = strings.ReplaceAll(name, k, v)
|
||||
}
|
||||
return name
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/fs"
|
||||
|
@ -140,7 +139,7 @@ func filterDirs(objs []model.Obj) []DirResp {
|
|||
for _, obj := range objs {
|
||||
if obj.IsDir() {
|
||||
dirs = append(dirs, DirResp{
|
||||
Name: utils.MappingName(obj.GetName(), conf.FilenameCharMap),
|
||||
Name: obj.GetName(),
|
||||
Modified: obj.ModTime(),
|
||||
})
|
||||
}
|
||||
|
@ -187,7 +186,7 @@ func toObjsResp(objs []model.Obj, parent string, encrypt bool) []ObjResp {
|
|||
thumb = t.Thumb()
|
||||
}
|
||||
resp = append(resp, ObjResp{
|
||||
Name: utils.MappingName(obj.GetName(), conf.FilenameCharMap),
|
||||
Name: obj.GetName(),
|
||||
Size: obj.GetSize(),
|
||||
IsDir: obj.IsDir(),
|
||||
Modified: obj.ModTime(),
|
||||
|
@ -285,7 +284,7 @@ func FsGet(c *gin.Context) {
|
|||
parentMeta, _ := db.GetNearestMeta(parentPath)
|
||||
common.SuccessResp(c, FsGetResp{
|
||||
ObjResp: ObjResp{
|
||||
Name: utils.MappingName(obj.GetName(), conf.FilenameCharMap),
|
||||
Name: obj.GetName(),
|
||||
Size: obj.GetSize(),
|
||||
IsDir: obj.IsDir(),
|
||||
Modified: obj.ModTime(),
|
||||
|
|
|
@ -10,11 +10,9 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/fs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
// slashClean is equivalent to but slightly more efficient than
|
||||
|
@ -101,7 +99,7 @@ func walkFS(ctx context.Context, depth int, name string, info model.Obj, walkFn
|
|||
}
|
||||
|
||||
for _, fileInfo := range objs {
|
||||
filename := path.Join(name, utils.MappingName(fileInfo.GetName(), conf.FilenameCharMap))
|
||||
filename := path.Join(name, fileInfo.GetName())
|
||||
if err != nil {
|
||||
if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir {
|
||||
return err
|
||||
|
|
|
@ -15,9 +15,7 @@ import (
|
|||
"path"
|
||||
"strconv"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
// Proppatch describes a property update instruction as defined in RFC 4918.
|
||||
|
@ -199,7 +197,7 @@ func props(ctx context.Context, ls LockSystem, fi model.Obj, pnames []xml.Name)
|
|||
}
|
||||
// Otherwise, it must either be a live property or we don't know it.
|
||||
if prop := liveProps[pn]; prop.findFn != nil && (prop.dir || !isDir) {
|
||||
innerXML, err := prop.findFn(ctx, ls, utils.MappingName(fi.GetName(), conf.FilenameCharMap), fi)
|
||||
innerXML, err := prop.findFn(ctx, ls, fi.GetName(), fi)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -375,7 +373,7 @@ func findDisplayName(ctx context.Context, ls LockSystem, name string, fi model.O
|
|||
// Hide the real name of a possibly prefixed root directory.
|
||||
return "", nil
|
||||
}
|
||||
return escapeXML(utils.MappingName(fi.GetName(), conf.FilenameCharMap)), nil
|
||||
return escapeXML(fi.GetName()), nil
|
||||
}
|
||||
|
||||
func findContentLength(ctx context.Context, ls LockSystem, name string, fi model.Obj) (string, error) {
|
||||
|
|
Loading…
Reference in New Issue