Feat: list files for shared folder

This commit is contained in:
HFO4
2020-01-30 13:21:21 +08:00
parent a0c320b964
commit 0edbbfc9ea
7 changed files with 115 additions and 26 deletions

View File

@@ -20,13 +20,22 @@ func (fs *FileSystem) IsPathExist(path string) (bool, *model.Folder) {
}
// 递归步入目录
// TODO:装入树形缓存
// TODO:测试新增
var currentFolder *model.Folder
// 如果已设定目录对象,则从给定目录向下遍历
if len(fs.DirTarget) > 0 {
currentFolder = &fs.DirTarget[0]
}
for _, folderName := range pathList {
var err error
// 根目录
if folderName == "/" {
if currentFolder != nil {
continue
}
currentFolder, err = fs.User.Root()
if err != nil {
return false, nil

View File

@@ -31,6 +31,8 @@ func BuildSiteConfig(settings map[string]string, user *model.User) Response {
var userRes User
if user != nil {
userRes = BuildUser(*user)
} else {
userRes = BuildUser(*model.NewAnonymousUser())
}
return Response{
Data: SiteConfig{

View File

@@ -43,6 +43,7 @@ type group struct {
AllowTorrentDownload bool `json:"allowTorrentDownload"`
AllowArchiveDownload bool `json:"allowArchiveDownload"`
ShareFreeEnabled bool `json:"shareFree"`
ShareDownload bool `json:"shareDownload"`
}
type storage struct {
@@ -78,6 +79,7 @@ func BuildUser(user model.User) User {
AllowTorrentDownload: aria2Option[2],
AllowArchiveDownload: user.Group.OptionsSerialized.ArchiveDownloadEnabled,
ShareFreeEnabled: user.Group.OptionsSerialized.ShareFreeEnabled,
ShareDownload: user.Group.OptionsSerialized.ShareDownloadEnabled,
},
}
}