File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
23
23
type Alias struct {
24
24
model.Storage
25
25
Addition
26
+ rootOrder []string
26
27
pathMap map [string ][]string
27
28
autoFlatten bool
28
29
oneKey string
@@ -40,13 +41,18 @@ func (d *Alias) Init(ctx context.Context) error {
40
41
if d .Paths == "" {
41
42
return errors .New ("paths is required" )
42
43
}
44
+ paths := strings .Split (d .Paths , "\n " )
45
+ d .rootOrder = make ([]string , 0 , len (paths ))
43
46
d .pathMap = make (map [string ][]string )
44
- for _ , path := range strings . Split ( d . Paths , " \n " ) {
47
+ for _ , path := range paths {
45
48
path = strings .TrimSpace (path )
46
49
if path == "" {
47
50
continue
48
51
}
49
52
k , v := getPair (path )
53
+ if _ , ok := d .pathMap [k ]; ! ok {
54
+ d .rootOrder = append (d .rootOrder , k )
55
+ }
50
56
d .pathMap [k ] = append (d .pathMap [k ], v )
51
57
}
52
58
if len (d .pathMap ) == 1 {
@@ -62,6 +68,7 @@ func (d *Alias) Init(ctx context.Context) error {
62
68
}
63
69
64
70
func (d * Alias ) Drop (ctx context.Context ) error {
71
+ d .rootOrder = nil
65
72
d .pathMap = nil
66
73
return nil
67
74
}
Original file line number Diff line number Diff line change @@ -19,14 +19,15 @@ import (
19
19
func (d * Alias ) listRoot (ctx context.Context , withDetails bool ) []model.Obj {
20
20
var objs []model.Obj
21
21
var wg sync.WaitGroup
22
- for k , v := range d .pathMap {
22
+ for _ , k := range d .rootOrder {
23
23
obj := model.Object {
24
24
Name : k ,
25
25
IsFolder : true ,
26
26
Modified : d .Modified ,
27
27
}
28
28
idx := len (objs )
29
29
objs = append (objs , & obj )
30
+ v := d .pathMap [k ]
30
31
if ! withDetails || len (v ) != 1 {
31
32
continue
32
33
}
You can’t perform that action at this time.
0 commit comments