-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(drivers): add aliyun_pds driver #1936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
Signed-off-by: MadDogOwner <[email protected]>
|
我记得阿里云盘企业版自带一个在线解压,要不要也实现一下 |
| file := &stream.FileStream{ | ||
| Obj: streamer, | ||
| Reader: streamer, | ||
| Mimetype: streamer.GetMimetype(), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要这样一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这部分代码是从 aliyundrive 复制过来的,如果有问题,麻烦改一下,感谢!
| var localFile *os.File | ||
| if fileStream, ok := file.Reader.(*stream.FileStream); ok { | ||
| localFile, _ = fileStream.Reader.(*os.File) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
根据stream.CacheFullAndWriter的写法,缓存到临时文件里的FileStream的Reader是*buffer.PeekFile类型。根据local.Put的写法,本机存储返回的Link是RangeReader类型。所以如果我想的没错的话,这个转换恐怕总是失败。
| 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应当
- 首先判断文件是否已经具有 SHA1 值
- 使用
stream.CacheFullAndHash计算 SHA1
Signed-off-by: MadDogOwner <[email protected]>
Description / 描述
增加阿里云盘企业版
Motivation and Context / 背景
https://github.com/orgs/OpenListTeam/discussions/170
How Has This Been Tested? / 测试
修改自老阿里云盘驱动,个人测试使用1个月,没太大问题。
获取Refresh Token有点麻烦,我这边浏览器F12无法直接获取,暂不提供方法。
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。