mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: archive download in shared folder
This commit is contained in:
@@ -33,6 +33,23 @@ func (fs *FileSystem) Compress(ctx context.Context, folderIDs, fileIDs []uint) (
|
||||
return "", ErrDBListObjects
|
||||
}
|
||||
|
||||
// 如果上下文限制了父目录,则进行检查
|
||||
if parent, ok := ctx.Value(fsctx.LimitParentCtx).(*model.Folder); ok {
|
||||
// 检查目录
|
||||
for _, folder := range folders {
|
||||
if *folder.ParentID != parent.ID {
|
||||
return "", ErrObjectNotExist
|
||||
}
|
||||
}
|
||||
|
||||
// 检查文件
|
||||
for _, file := range files {
|
||||
if file.FolderID != parent.ID {
|
||||
return "", ErrObjectNotExist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试获取请求上下文,以便于后续检查用户取消任务
|
||||
reqContext := ctx
|
||||
ginCtx, ok := ctx.Value(fsctx.GinCtx).(*gin.Context)
|
||||
|
||||
@@ -29,4 +29,6 @@ const (
|
||||
FileSizeCtx
|
||||
// ShareKeyCtx 分享文件的 HashID
|
||||
ShareKeyCtx
|
||||
// LimitParentCtx 限制父目录
|
||||
LimitParentCtx
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user