diff --git a/models/group.go b/models/group.go index 1107f30..b45991b 100644 --- a/models/group.go +++ b/models/group.go @@ -13,7 +13,6 @@ type Group struct { MaxStorage uint64 ShareEnabled bool WebDAVEnabled bool - Aria2Option string Color string SpeedLimit int Options string `json:"-",gorm:"type:text"` @@ -36,18 +35,6 @@ type GroupOption struct { Aria2Options []interface{} `json:"aria2_options,omitempty"` // 离线下载用户组配置 } -// GetAria2Option 获取用户离线下载设备 -func (group *Group) GetAria2Option() [3]bool { - if len(group.Aria2Option) != 5 { - return [3]bool{false, false, false} - } - return [3]bool{ - group.Aria2Option[0] == '1', - group.Aria2Option[2] == '1', - group.Aria2Option[4] == '1', - } -} - // GetGroupByID 用ID获取用户组 func GetGroupByID(ID interface{}) (Group, error) { var group Group diff --git a/models/group_test.go b/models/group_test.go index 3c3e1d1..2f487ce 100644 --- a/models/group_test.go +++ b/models/group_test.go @@ -63,22 +63,6 @@ func TestGroup_AfterFind(t *testing.T) { asserts.Equal(testCase.PolicyList, []uint{}) } -func TestGroup_GetAria2Option(t *testing.T) { - asserts := assert.New(t) - group := Group{} - // 格式错误 - { - group.Aria2Option = "123" - asserts.Equal([3]bool{false, false, false}, group.GetAria2Option()) - } - - // 正常 - { - group.Aria2Option = "1,1,0" - asserts.Equal([3]bool{true, true, false}, group.GetAria2Option()) - } -} - func TestGroup_BeforeSave(t *testing.T) { asserts := assert.New(t) group := Group{ diff --git a/models/migration.go b/models/migration.go index 2c8e9aa..4600bdb 100644 --- a/models/migration.go +++ b/models/migration.go @@ -188,7 +188,6 @@ func addDefaultGroups() { ShareEnabled: true, Color: "danger", WebDAVEnabled: true, - Aria2Option: "0,0,0", OptionsSerialized: GroupOption{ ArchiveDownload: true, ArchiveTask: true, @@ -211,7 +210,6 @@ func addDefaultGroups() { ShareEnabled: true, Color: "danger", WebDAVEnabled: true, - Aria2Option: "0,0,0", } if err := DB.Create(&defaultAdminGroup).Error; err != nil { util.Log().Panic("无法创建初始注册会员用户组, %s", err) diff --git a/pkg/filesystem/driver/cos/handller.go b/pkg/filesystem/driver/cos/handller.go index 1445c14..58b0005 100644 --- a/pkg/filesystem/driver/cos/handller.go +++ b/pkg/filesystem/driver/cos/handller.go @@ -67,6 +67,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, downloadURL, nil, request.WithContext(ctx), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/driver/onedrive/handller.go b/pkg/filesystem/driver/onedrive/handller.go index 6663545..eac2533 100644 --- a/pkg/filesystem/driver/onedrive/handller.go +++ b/pkg/filesystem/driver/onedrive/handller.go @@ -10,6 +10,7 @@ import ( "github.com/HFO4/cloudreve/pkg/serializer" "io" "net/url" + "time" ) // Driver OneDrive 适配器 @@ -40,6 +41,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, downloadURL, nil, request.WithContext(ctx), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/driver/oss/handller.go b/pkg/filesystem/driver/oss/handller.go index 98613cd..aec07c8 100644 --- a/pkg/filesystem/driver/oss/handller.go +++ b/pkg/filesystem/driver/oss/handller.go @@ -99,6 +99,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, downloadURL, nil, request.WithContext(ctx), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/driver/qiniu/handller.go b/pkg/filesystem/driver/qiniu/handller.go index bf5a4b1..1c7ef13 100644 --- a/pkg/filesystem/driver/qiniu/handller.go +++ b/pkg/filesystem/driver/qiniu/handller.go @@ -50,6 +50,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, request.WithHeader( http.Header{"Cache-Control": {"no-cache", "no-store", "must-revalidate"}}, ), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/driver/remote/handler.go b/pkg/filesystem/driver/remote/handler.go index ac6ce50..8c863b1 100644 --- a/pkg/filesystem/driver/remote/handler.go +++ b/pkg/filesystem/driver/remote/handler.go @@ -17,6 +17,7 @@ import ( "net/url" "path" "strings" + "time" ) // Driver 远程存储策略适配器 @@ -70,6 +71,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, downloadURL, nil, request.WithContext(ctx), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/driver/upyun/handller.go b/pkg/filesystem/driver/upyun/handller.go index 7ccab2a..08fa585 100644 --- a/pkg/filesystem/driver/upyun/handller.go +++ b/pkg/filesystem/driver/upyun/handller.go @@ -68,6 +68,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, request.WithHeader( http.Header{"Cache-Control": {"no-cache", "no-store", "must-revalidate"}}, ), + request.WithTimeout(time.Duration(0)), ).CheckHTTPResponse(200).GetRSCloser() if err != nil { return nil, err diff --git a/pkg/filesystem/manage.go b/pkg/filesystem/manage.go index 650f9e5..6e82c00 100644 --- a/pkg/filesystem/manage.go +++ b/pkg/filesystem/manage.go @@ -257,6 +257,7 @@ func (fs *FileSystem) List(ctx context.Context, dirPath string, pathProcessor fu if !isExist { return []Object{}, nil } + fs.SetTargetDir(&[]model.Folder{*folder}) var parentPath = path.Join(folder.Position, folder.Name) var childFolders []model.Folder diff --git a/pkg/serializer/user.go b/pkg/serializer/user.go index 0f11e04..193cd4b 100644 --- a/pkg/serializer/user.go +++ b/pkg/serializer/user.go @@ -44,6 +44,7 @@ type group struct { AllowArchiveDownload bool `json:"allowArchiveDownload"` ShareFreeEnabled bool `json:"shareFree"` ShareDownload bool `json:"shareDownload"` + CompressEnabled bool `json:"compress"` } type storage struct { @@ -54,7 +55,6 @@ type storage struct { // BuildUser 序列化用户 func BuildUser(user model.User) User { - aria2Option := user.Group.GetAria2Option() return User{ ID: user.ID, Email: user.Email, @@ -75,11 +75,11 @@ func BuildUser(user model.User) User { ID: user.GroupID, Name: user.Group.Name, AllowShare: user.Group.ShareEnabled, - AllowRemoteDownload: aria2Option[0], - AllowTorrentDownload: aria2Option[2], + AllowRemoteDownload: user.Group.OptionsSerialized.Aria2, AllowArchiveDownload: user.Group.OptionsSerialized.ArchiveDownload, ShareFreeEnabled: user.Group.OptionsSerialized.ShareFree, ShareDownload: user.Group.OptionsSerialized.ShareDownload, + CompressEnabled: user.Group.OptionsSerialized.ArchiveTask, }, } } diff --git a/service/explorer/directory.go b/service/explorer/directory.go index 3ee5064..f603bea 100644 --- a/service/explorer/directory.go +++ b/service/explorer/directory.go @@ -31,9 +31,17 @@ func (service *DirectoryService) ListDirectory(c *gin.Context) serializer.Respon return serializer.Err(serializer.CodeCreateFolderFailed, err.Error(), err) } + var parentID uint + if len(fs.DirTarget) > 0 { + parentID = fs.DirTarget[0].ID + } + return serializer.Response{ Code: 0, - Data: objects, + Data: map[string]interface{}{ + "parent": parentID, + "objects": objects, + }, } } diff --git a/service/share/visit.go b/service/share/visit.go index 6d54cc1..1737143 100644 --- a/service/share/visit.go +++ b/service/share/visit.go @@ -215,9 +215,17 @@ func (service *Service) List(c *gin.Context) serializer.Response { return serializer.Err(serializer.CodeCreateFolderFailed, err.Error(), err) } + var parentID uint + if len(fs.DirTarget) > 0 { + parentID = fs.DirTarget[0].ID + } + return serializer.Response{ Code: 0, - Data: objects, + Data: map[string]interface{}{ + "parent": parentID, + "objects": objects, + }, } }