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 (
2323type Alias struct {
2424 model.Storage
2525 Addition
26+ rootOrder []string
2627 pathMap map [string ][]string
2728 autoFlatten bool
2829 oneKey string
@@ -40,13 +41,18 @@ func (d *Alias) Init(ctx context.Context) error {
4041 if d .Paths == "" {
4142 return errors .New ("paths is required" )
4243 }
44+ paths := strings .Split (d .Paths , "\n " )
45+ d .rootOrder = make ([]string , 0 , len (paths ))
4346 d .pathMap = make (map [string ][]string )
44- for _ , path := range strings . Split ( d . Paths , " \n " ) {
47+ for _ , path := range paths {
4548 path = strings .TrimSpace (path )
4649 if path == "" {
4750 continue
4851 }
4952 k , v := getPair (path )
53+ if _ , ok := d .pathMap [k ]; ! ok {
54+ d .rootOrder = append (d .rootOrder , k )
55+ }
5056 d .pathMap [k ] = append (d .pathMap [k ], v )
5157 }
5258 if len (d .pathMap ) == 1 {
@@ -62,6 +68,7 @@ func (d *Alias) Init(ctx context.Context) error {
6268}
6369
6470func (d * Alias ) Drop (ctx context.Context ) error {
71+ d .rootOrder = nil
6572 d .pathMap = nil
6673 return nil
6774}
Original file line number Diff line number Diff line change @@ -19,14 +19,15 @@ import (
1919func (d * Alias ) listRoot (ctx context.Context , withDetails bool ) []model.Obj {
2020 var objs []model.Obj
2121 var wg sync.WaitGroup
22- for k , v := range d .pathMap {
22+ for _ , k := range d .rootOrder {
2323 obj := model.Object {
2424 Name : k ,
2525 IsFolder : true ,
2626 Modified : d .Modified ,
2727 }
2828 idx := len (objs )
2929 objs = append (objs , & obj )
30+ v := d .pathMap [k ]
3031 if ! withDetails || len (v ) != 1 {
3132 continue
3233 }
You can’t perform that action at this time.
0 commit comments