Skip to content

Commit 46770f7

Browse files
committed
Implement GetRoot
1 parent 65dd96c commit 46770f7

4 files changed

Lines changed: 31 additions & 28 deletions

File tree

drivers/alias/driver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ func (d *Alias) Drop(ctx context.Context) error {
6666
return nil
6767
}
6868

69+
func (d *Alias) GetRoot(ctx context.Context) (model.Obj, error) {
70+
return &model.Object{
71+
Name: "Root",
72+
IsFolder: true,
73+
Path: "/",
74+
}, nil
75+
}
76+
6977
func (d *Alias) Get(ctx context.Context, path string) (model.Obj, error) {
70-
if utils.PathEqual(path, "/") {
71-
return &model.Object{
72-
Name: "Root",
73-
IsFolder: true,
74-
Path: "/",
75-
}, nil
76-
}
7778
root, sub := d.getRootAndPath(path)
7879
dsts, ok := d.pathMap[root]
7980
if !ok {

drivers/crypt/driver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,15 @@ func (d *Crypt) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
186186
return result, nil
187187
}
188188

189+
func (d *Crypt) GetRoot(ctx context.Context) (model.Obj, error) {
190+
return &model.Object{
191+
Name: "Root",
192+
IsFolder: true,
193+
Path: "/",
194+
}, nil
195+
}
196+
189197
func (d *Crypt) Get(ctx context.Context, path string) (model.Obj, error) {
190-
if utils.PathEqual(path, "/") {
191-
return &model.Object{
192-
Name: "Root",
193-
IsFolder: true,
194-
Path: "/",
195-
}, nil
196-
}
197198
remoteFullPath := ""
198199
var remoteObj model.Obj
199200
var err, err2 error

drivers/netease_music/driver.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ func (d *NeteaseMusic) Drop(ctx context.Context) error {
4242
return nil
4343
}
4444

45-
func (d *NeteaseMusic) Get(ctx context.Context, path string) (model.Obj, error) {
46-
if path == "/" {
47-
return &model.Object{
48-
IsFolder: true,
49-
Path: path,
50-
}, nil
51-
}
45+
func (d *NeteaseMusic) GetRoot(ctx context.Context) (model.Obj, error) {
46+
return &model.Object{
47+
IsFolder: true,
48+
Path: path,
49+
}, nil
50+
}
5251

52+
func (d *NeteaseMusic) Get(ctx context.Context, path string) (model.Obj, error) {
5353
fragments := strings.Split(path, "/")
5454
if len(fragments) > 1 {
5555
fileName := fragments[1]

drivers/strm/driver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ func (d *Strm) Drop(ctx context.Context) error {
8989
return nil
9090
}
9191

92+
func (d *Strm) GetRoot(ctx context.Context) (model.Obj, error) {
93+
return &model.Object{
94+
Name: "Root",
95+
IsFolder: true,
96+
Path: "/",
97+
}, nil
98+
}
99+
92100
func (d *Strm) Get(ctx context.Context, path string) (model.Obj, error) {
93-
if utils.PathEqual(path, "/") {
94-
return &model.Object{
95-
Name: "Root",
96-
IsFolder: true,
97-
Path: "/",
98-
}, nil
99-
}
100101
root, sub := d.getRootAndPath(path)
101102
dsts, ok := d.pathMap[root]
102103
if !ok {

0 commit comments

Comments
 (0)