mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: re-save shared folder to user's space
This commit is contained in:
@@ -50,8 +50,8 @@ func (service *ShareGetService) Get(c *gin.Context) serializer.Response {
|
||||
share.Viewed()
|
||||
}
|
||||
|
||||
// 如果已经下载过,不需要付积分
|
||||
if share.WasDownloadedBy(user, c) {
|
||||
// 如果已经下载过或者是自己的分享,不需要付积分
|
||||
if share.UserID == user.ID || share.WasDownloadedBy(user, c) {
|
||||
share.Score = 0
|
||||
}
|
||||
|
||||
@@ -81,6 +81,11 @@ func (service *ShareService) CreateDownloadSession(c *gin.Context) serializer.Re
|
||||
return serializer.Err(serializer.CodePolicyNotAllowed, "源文件不存在", err)
|
||||
}
|
||||
|
||||
// 重设根目录
|
||||
if share.IsDir {
|
||||
fs.Root = &fs.DirTarget[0]
|
||||
}
|
||||
|
||||
// 取得下载地址
|
||||
downloadURL, err := fs.GetDownloadURL(context.Background(), service.Path, "download_timeout")
|
||||
if err != nil {
|
||||
@@ -189,8 +194,8 @@ func (service *ShareService) List(c *gin.Context) serializer.Response {
|
||||
defer cancel()
|
||||
|
||||
// 重设根目录
|
||||
fs.SetTargetDir(&[]model.Folder{*share.GetSource().(*model.Folder)})
|
||||
fs.DirTarget[0].Name = "/"
|
||||
fs.Root = share.GetSource().(*model.Folder)
|
||||
fs.Root.Name = "/"
|
||||
|
||||
// 分享Key上下文
|
||||
ctx = context.WithValue(ctx, fsctx.ShareKeyCtx, hashid.HashID(share.ID, hashid.ShareID))
|
||||
|
||||
Reference in New Issue
Block a user