Skip to content

Commit

Permalink
fix: is the root folder required (close #1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Sep 11, 2022
1 parent fba1471 commit 969018d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
12 changes: 4 additions & 8 deletions drivers/189pc/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ import (
)

type Addition struct {
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
VCode string `json:"validate_code"`
RootFolderID string `json:"root_folder_id"`
Username string `json:"username" required:"true"`
Password string `json:"password" required:"true"`
VCode string `json:"validate_code"`
driver.RootID
OrderBy string `json:"order_by" type:"select" options:"filename,filesize,lastOpTime" default:"filename"`
OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
Type string `json:"type" type:"select" options:"personal,family" default:"personal"`
FamilyID string `json:"family_id"`
RapidUpload bool `json:"rapid_upload"`
}

func (a Addition) GetRootId() string {
return a.RootFolderID
}

var config = driver.Config{
Name: "189CloudPC",
DefaultRoot: "-11",
Expand Down
4 changes: 2 additions & 2 deletions internal/driver/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ type IRootId interface {
}

type RootPath struct {
RootFolderPath string `json:"root_folder_path" required:"true"`
RootFolderPath string `json:"root_folder_path"`
}

type RootID struct {
RootFolderID string `json:"root_folder_id" required:"true"`
RootFolderID string `json:"root_folder_id"`
}

func (r RootPath) GetRootPath() string {
Expand Down
7 changes: 5 additions & 2 deletions internal/op/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
if tag.Get("type") != "" {
item.Type = tag.Get("type")
}
if (item.Name == "root_folder_id" || item.Name == "root_folder_path") && item.Default == "" {
item.Default = defaultRoot
if item.Name == "root_folder_id" || item.Name == "root_folder_path" {
if item.Default == "" {
item.Default = defaultRoot
}
item.Required = item.Default != ""
}
// set default type to string
if item.Type == "" {
Expand Down

0 comments on commit 969018d

Please sign in to comment.