mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: download archived file anonymously
This commit is contained in:
@@ -38,13 +38,16 @@ func (fs *FileSystem) Compress(ctx context.Context, folderIDs, fileIDs []uint) (
|
||||
}
|
||||
|
||||
// 创建临时压缩文件
|
||||
zipFilePath := filepath.Join(model.GetSettingByName("temp_path"), fmt.Sprintf("archive_%d.zip", time.Now().UnixNano()))
|
||||
zipFilePath := filepath.Join(
|
||||
model.GetSettingByName("temp_path"),
|
||||
fmt.Sprintf("archive_%d.zip", time.Now().UnixNano()),
|
||||
)
|
||||
zipFile, err := util.CreatNestedFile(zipFilePath)
|
||||
defer zipFile.Close()
|
||||
if err != nil {
|
||||
util.Log().Warning("%s", err)
|
||||
return "", err
|
||||
}
|
||||
defer zipFile.Close()
|
||||
|
||||
// 创建压缩文件Writer
|
||||
zipWriter := zip.NewWriter(zipFile)
|
||||
|
||||
@@ -2,7 +2,6 @@ package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/HFO4/cloudreve/models"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/local"
|
||||
"github.com/HFO4/cloudreve/pkg/filesystem/response"
|
||||
@@ -121,10 +120,11 @@ func (fs *FileSystem) dispatchHandler() error {
|
||||
}
|
||||
|
||||
// NewFileSystemFromContext 从gin.Context创建文件系统
|
||||
// TODO 用户不存在时使用匿名文件系统
|
||||
func NewFileSystemFromContext(c *gin.Context) (*FileSystem, error) {
|
||||
user, exist := c.Get("user")
|
||||
if !exist {
|
||||
return nil, errors.New("无法找到用户")
|
||||
return NewAnonymousFileSystem()
|
||||
}
|
||||
fs, err := NewFileSystem(user.(*model.User))
|
||||
return fs, err
|
||||
|
||||
@@ -40,6 +40,7 @@ type group struct {
|
||||
AllowShare bool `json:"allowShare"`
|
||||
AllowRemoteDownload bool `json:"allowRemoteDownload"`
|
||||
AllowTorrentDownload bool `json:"allowTorrentDownload"`
|
||||
AllowArchiveDownload bool `json:"allowArchiveDownload"`
|
||||
}
|
||||
|
||||
type storage struct {
|
||||
@@ -72,6 +73,7 @@ func BuildUser(user model.User) User {
|
||||
AllowShare: user.Group.ShareEnabled,
|
||||
AllowRemoteDownload: aria2Option[0],
|
||||
AllowTorrentDownload: aria2Option[2],
|
||||
AllowArchiveDownload: user.Group.OptionsSerialized.ArchiveDownloadEnabled,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user