From f0cc6d80080b3824f355440387b6ad9e9fef20b8 Mon Sep 17 00:00:00 2001 From: iikira <2571583272@qq.com> Date: Mon, 6 Apr 2020 17:56:26 +0800 Subject: [PATCH] v3.6.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #858, 更改默认的下载模式 fix #872, 优化上传的重试判断 fix #845, 修复md5显示不正确 fix #513, 已增加上传限速 --- .github/RELEASE_TEMPLATE.md | 11 ++++-- README.md | 2 + build.sh | 2 +- main.go | 4 +- requester/multipartreader/multipartreader.go | 4 +- requester/rio/buf.go | 7 ++++ requester/uploader/block.go | 4 +- requester/uploader/block_test.go | 39 +++++++++++++++++++ resource_windows_386.syso | Bin 69255 -> 69255 bytes resource_windows_amd64.syso | Bin 69255 -> 69255 bytes versioninfo.json | 10 ++--- 11 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 requester/uploader/block_test.go diff --git a/.github/RELEASE_TEMPLATE.md b/.github/RELEASE_TEMPLATE.md index 150ab02..3244197 100644 --- a/.github/RELEASE_TEMPLATE.md +++ b/.github/RELEASE_TEMPLATE.md @@ -1,9 +1,12 @@ # 更新日志: -1. 新增上传、下载设置限速 -2. 优化Windows下载大文件时的处理性能, [点此查看详情和设置方法](https://github.com/iikira/BaiduPCS-Go/wiki/Windows%E5%A6%82%E4%BD%95%E5%BC%80%E5%90%AF%E4%BC%98%E5%8C%96%E4%B8%8B%E8%BD%BD%E5%A4%A7%E6%96%87%E4%BB%B6%E6%97%B6%E7%9A%84%E5%A4%84%E7%90%86%E6%80%A7%E8%83%BD) -3. 更新下载器 -4. 多处bug修复 +1. 修复文件md5显示错误 +2. 修复无法上传 +3. 修复分享列表获取不到密码 +4. 更新上传、下载处理流程,优化重试的判断条件 +5. 更新download命令, 移除之前的-stream -share -locate等参数,新增-mode参数, 设置下载模式 +6. 更新默认的下载模式mode为locate, 参见 [#858](https://github.com/iikira/BaiduPCS-Go/issues/858) +7. 移除后台下载(bg)功能 个人项目bug在所难免! 欢迎提 issue 和 pull request!!. diff --git a/README.md b/README.md index 37bda11..e555e43 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ This project was largely inspired by [GangZhuo/BaiduPCS](https://github.com/Gang Go语言程序, 可直接在[发布页](https://github.com/iikira/BaiduPCS-Go/releases)下载使用. +可在这里下载最新commit对应的**测试版**: https://ci.appveyor.com/project/iikira/baidupcs-go/build/artifacts + 如果程序运行时输出乱码, 请检查下终端的编码方式是否为 `UTF-8`. 使用本程序之前, 建议学习一些 linux 基础知识 和 基础命令. diff --git a/build.sh b/build.sh index b01f86c..c0dd800 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ name="BaiduPCS-Go" version=$1 if [ "$1" = "" ]; then - version=v3.6.1 + version=v3.6.2 fi output="out/" diff --git a/main.go b/main.go index c541aab..60f4314 100644 --- a/main.go +++ b/main.go @@ -54,7 +54,7 @@ const ( var ( // Version 版本号 - Version = "v3.6.1-devel" + Version = "v3.6.2-devel" historyFilePath = filepath.Join(pcsconfig.GetConfigDir(), "pcs_command_history.txt") reloadFn = func(c *cli.Context) error { @@ -96,7 +96,7 @@ func main() { app.Name = "BaiduPCS-Go" app.Version = Version app.Author = "iikira/BaiduPCS-Go: https://github.com/iikira/BaiduPCS-Go" - app.Copyright = "(c) 2016-2019 iikira." + app.Copyright = "(c) 2016-2020 iikira." app.Usage = "百度网盘客户端 for " + runtime.GOOS + "/" + runtime.GOARCH app.Description = `BaiduPCS-Go 使用Go语言编写的百度网盘命令行客户端, 为操作百度网盘, 提供实用功能. 具体功能, 参见 COMMANDS 列表 diff --git a/requester/multipartreader/multipartreader.go b/requester/multipartreader/multipartreader.go index a7f00f4..ea1ce25 100644 --- a/requester/multipartreader/multipartreader.go +++ b/requester/multipartreader/multipartreader.go @@ -57,7 +57,7 @@ func NewMultipartReader() (mr *MultipartReader) { // AddFormFeild 增加 form 表单 func (mr *MultipartReader) AddFormFeild(fieldname string, readerlen rio.ReaderLen) { - if (readerlen == nil) { + if readerlen == nil { return } @@ -71,7 +71,7 @@ func (mr *MultipartReader) AddFormFeild(fieldname string, readerlen rio.ReaderLe // AddFormFile 增加 form 文件表单 func (mr *MultipartReader) AddFormFile(fieldname, filename string, readerlen64 rio.ReaderLen64) { - if (readerlen64 == nil) { + if readerlen64 == nil { return } diff --git a/requester/rio/buf.go b/requester/rio/buf.go index b5912b2..7123506 100644 --- a/requester/rio/buf.go +++ b/requester/rio/buf.go @@ -16,6 +16,13 @@ func NewBuffer(buf []byte) *Buffer { } } +// ReadAt 实现 io.ReadAt 接口 +// 不进行越界检查 +func (b *Buffer) ReadAt(p []byte, off int64) (n int, err error) { + n = copy(p, b.Buf[off:]) + return n, nil +} + // WriteAt 实现 io.WriterAt 接口 // 不进行越界检查 func (b *Buffer) WriteAt(p []byte, off int64) (n int, err error) { diff --git a/requester/uploader/block.go b/requester/uploader/block.go index c993f13..9767924 100644 --- a/requester/uploader/block.go +++ b/requester/uploader/block.go @@ -72,11 +72,11 @@ func (fb *fileBlock) Read(b []byte) (n int, err error) { fb.mu.Lock() defer fb.mu.Unlock() - if fb.readed+fb.readRange.Begin >= fb.readRange.End { + left := int(fb.Left()) + if left <= 0 { return 0, io.EOF } - left := int(fb.Left()) if len(b) > left { n, err = fb.readerAt.ReadAt(b[:left], fb.readed+fb.readRange.Begin) } else { diff --git a/requester/uploader/block_test.go b/requester/uploader/block_test.go new file mode 100644 index 0000000..590768e --- /dev/null +++ b/requester/uploader/block_test.go @@ -0,0 +1,39 @@ +package uploader_test + +import ( + "fmt" + "github.com/iikira/BaiduPCS-Go/pcsutil/cachepool" + "github.com/iikira/BaiduPCS-Go/requester/rio" + "github.com/iikira/BaiduPCS-Go/requester/transfer" + "github.com/iikira/BaiduPCS-Go/requester/uploader" + "io" + "testing" +) + +var ( + blockList = uploader.SplitBlock(10000, 999) +) + +func TestSplitBlock(t *testing.T) { + for k, e := range blockList { + fmt.Printf("%d %#v\n", k, e) + } +} + +func TestSplitUnitRead(t *testing.T) { + var size int64 = 65536*2+3432 + buffer := rio.NewBuffer(cachepool.RawMallocByteSlice(int(size))) + unit := uploader.NewBufioSplitUnit(buffer, transfer.Range{Begin: 2, End: size}, nil, nil) + + buf := cachepool.RawMallocByteSlice(1022) + for { + n, err := unit.Read(buf) + if err != nil { + if err == io.EOF { + break + } + t.Fatalf("read error: %s\n", err) + } + fmt.Printf("n: %d, left: %d\n", n, unit.Left()) + } +} diff --git a/resource_windows_386.syso b/resource_windows_386.syso index a89cfb7210decf007b33c7088594376c3e374d94..7589bb7fd82b13cb5b490382fa85341578533acc 100644 GIT binary patch delta 50 zcmZpl%hEoVrC|#rJ0~X-0~-S~0|NuobOBDr*NjHf|8O!|GaE4&Ot<1tYkFYzJ-hN GGBW@lSPPH< diff --git a/resource_windows_amd64.syso b/resource_windows_amd64.syso index d3c44c4007339768fe2ffc15b3f21ec530445922..658a58745d31b6f2c5000e3a190f1a96bf6774a7 100644 GIT binary patch delta 50 zcmZpl%hEoVrC|#rJ0~X-0~-S~0|NuobOBDr*NjHf|8O!|GaE4&Ot<1tYkFYzJ-hN GGBW@lSPPH< diff --git a/versioninfo.json b/versioninfo.json index 51a7534..97527ba 100644 --- a/versioninfo.json +++ b/versioninfo.json @@ -3,13 +3,13 @@ "FileVersion": { "Major": 3, "Minor": 6, - "Patch": 1, + "Patch": 2, "Build": 0 }, "ProductVersion": { "Major": 3, "Minor": 6, - "Patch": 1, + "Patch": 2, "Build": 0 }, "FileFlagsMask": "3f", @@ -22,14 +22,14 @@ "Comments": "", "CompanyName": "iikira", "FileDescription": "百度网盘客户端", - "FileVersion": "v3.6.1", + "FileVersion": "v3.6.2", "InternalName": "", - "LegalCopyright": "© 2016-2019 iikira.", + "LegalCopyright": "© 2016-2020 iikira.", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", "ProductName": "BaiduPCS-Go", - "ProductVersion": "v3.6.1", + "ProductVersion": "v3.6.2", "SpecialBuild": "" }, "VarFileInfo": {