Skip to content

Conversation

@xrgzs
Copy link
Member

@xrgzs xrgzs commented Jan 8, 2026

Description / 描述

增加阿里云盘企业版

Motivation and Context / 背景

https://github.com/orgs/OpenListTeam/discussions/170

How Has This Been Tested? / 测试

修改自老阿里云盘驱动,个人测试使用1个月,没太大问题。

获取Refresh Token有点麻烦,我这边浏览器F12无法直接获取,暂不提供方法。

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

xrgzs added 6 commits January 8, 2026 10:55
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
@xrgzs xrgzs added Module: Driver Driver-Related Issue/PR enhancement labels Jan 8, 2026
@xrgzs xrgzs requested a review from KirCute January 8, 2026 03:52
@KirCute
Copy link
Member

KirCute commented Jan 8, 2026

我记得阿里云盘企业版自带一个在线解压,要不要也实现一下

Comment on lines +177 to +181
file := &stream.FileStream{
Obj: streamer,
Reader: streamer,
Mimetype: streamer.GetMimetype(),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要这样一下

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分代码是从 aliyundrive 复制过来的,如果有问题,麻烦改一下,感谢!

Comment on lines +199 to +202
var localFile *os.File
if fileStream, ok := file.Reader.(*stream.FileStream); ok {
localFile, _ = fileStream.Reader.(*os.File)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

根据stream.CacheFullAndWriter的写法,缓存到临时文件里的FileStreamReader*buffer.PeekFile类型。根据local.Put的写法,本机存储返回的LinkRangeReader类型。所以如果我想的没错的话,这个转换恐怕总是失败。

Comment on lines +238 to +262
delete(reqBody, "pre_hash")
h := sha1.New()
if localFile != nil {
if err = utils.CopyWithCtx(ctx, h, localFile, 0, nil); err != nil {
return err
}
if _, err = localFile.Seek(0, io.SeekStart); err != nil {
return err
}
} else {
tempFile, err := os.CreateTemp(conf.Conf.TempDir, "file-*")
if err != nil {
return err
}
defer func() {
_ = tempFile.Close()
_ = os.Remove(tempFile.Name())
}()
if err = utils.CopyWithCtx(ctx, io.MultiWriter(tempFile, h), file, 0, nil); err != nil {
return err
}
localFile = tempFile
}
reqBody["content_hash"] = hex.EncodeToString(h.Sum(nil))
reqBody["content_hash_name"] = "sha1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应当

  1. 首先判断文件是否已经具有 SHA1 值
  2. 使用stream.CacheFullAndHash计算 SHA1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Module: Driver Driver-Related Issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants