-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
150 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package local | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/alist-org/alist/v3/internal/driver" | ||
"github.com/alist-org/alist/v3/internal/errs" | ||
"github.com/alist-org/alist/v3/internal/model" | ||
"github.com/alist-org/alist/v3/pkg/utils" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type Template struct { | ||
model.Storage | ||
Addition | ||
} | ||
|
||
func (d *Template) Config() driver.Config { | ||
return config | ||
} | ||
|
||
func (d *Template) GetAddition() driver.Additional { | ||
return d.Addition | ||
} | ||
|
||
func (d *Template) Init(ctx context.Context, storage model.Storage) error { | ||
d.Storage = storage | ||
err := utils.Json.UnmarshalFromString(d.Storage.Addition, &d.Addition) | ||
if err != nil { | ||
return errors.Wrap(err, "error while unmarshal addition") | ||
} | ||
// TODO login / refresh token | ||
//operations.MustSaveDriverStorage(d) | ||
return err | ||
} | ||
|
||
func (d *Template) Drop(ctx context.Context) error { | ||
return nil | ||
} | ||
|
||
func (d *Template) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) { | ||
// TODO return the files list | ||
return nil, errs.NotImplement | ||
} | ||
|
||
func (d *Template) Get(ctx context.Context, path string) (model.Obj, error) { | ||
// TODO this is optional | ||
return nil, errs.NotImplement | ||
} | ||
|
||
func (d *Template) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) { | ||
// TODO return link of file | ||
return nil, errs.NotImplement | ||
} | ||
|
||
func (d *Template) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) error { | ||
// TODO create folder | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Move(ctx context.Context, srcObj, dstDir model.Obj) error { | ||
// TODO move obj | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Rename(ctx context.Context, srcObj model.Obj, newName string) error { | ||
// TODO rename obj | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Copy(ctx context.Context, srcObj, dstDir model.Obj) error { | ||
// TODO copy obj | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Remove(ctx context.Context, obj model.Obj) error { | ||
// TODO remove obj | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error { | ||
// TODO upload file | ||
return errs.NotImplement | ||
} | ||
|
||
func (d *Template) Other(ctx context.Context, args model.OtherArgs) (interface{}, error) { | ||
return nil, errs.NotSupport | ||
} | ||
|
||
var _ driver.Driver = (*Template)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package local | ||
|
||
import ( | ||
"github.com/alist-org/alist/v3/internal/driver" | ||
"github.com/alist-org/alist/v3/internal/operations" | ||
) | ||
|
||
type Addition struct { | ||
// Usually one of two | ||
driver.RootFolderPath | ||
driver.RootFolderId | ||
// define other | ||
Field string `json:"field" type:"select" required:"true" options:"a,b,c" default:"a"` | ||
} | ||
|
||
var config = driver.Config{ | ||
Name: "template", | ||
LocalSort: false, | ||
OnlyLocal: false, | ||
OnlyProxy: false, | ||
NoCache: false, | ||
NoUpload: false, | ||
NeedMs: false, | ||
DefaultRoot: "root, / or other", | ||
} | ||
|
||
func New() driver.Driver { | ||
return &Template{} | ||
} | ||
|
||
func init() { | ||
operations.RegisterDriver(config, New) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package local | ||
|
||
// do others that not defined in Driver interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters