diff --git a/.github/RELEASE_TEMPLATE.md b/.github/RELEASE_TEMPLATE.md index 3c932d2f..d5532d51 100644 --- a/.github/RELEASE_TEMPLATE.md +++ b/.github/RELEASE_TEMPLATE.md @@ -1,13 +1,11 @@ # 更新日志: -1. 修复下载无法断点续传的 bug; -2. 修复程序自动更新失败的 bug; -3. 支持分享/取消分享文件/目录; -4. 支持获取文件下载的直链; -5. 支持以分享文件的方式获取下载链接来下载,和以获取直链的方式来下载; -6. 新增 who 命令, 获取当前帐号; - -v3.5.1 的自动更新功能异常, 手动更新吧.... +1. 修复下载进度超出100%; +2. 修复修改文件夹名称导致文件夹消失; +3. 修复上传失败不输出错误; +4. 下载支持以流式文件的方式下载; +5. ls列目录,增加详细显示选项; +6. emm...; 个人项目bug在所难免! 欢迎提 issue 和 pull request!!. diff --git a/build.sh b/build.sh index 5d734a4f..f9050c52 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ name="BaiduPCS-Go" version=$1 if [ "$1" = "" ];then - version=v3.5.2 + version=v3.5.3 fi output="out/" diff --git a/debian/iphoneos-arm/control b/debian/iphoneos-arm/control index 58d382d5..f9bda764 100644 --- a/debian/iphoneos-arm/control +++ b/debian/iphoneos-arm/control @@ -1,5 +1,5 @@ Package: BaiduPCS-Go -Version: 3.5.2 +Version: 3.5.3 Homepage: https://github.com/iikira/BaiduPCS-Go Section: 实用工具 Priority: optional diff --git a/internal/pcscommand/cp_mv.go b/internal/pcscommand/cp_mv.go index 4f58370d..31de8c7d 100644 --- a/internal/pcscommand/cp_mv.go +++ b/internal/pcscommand/cp_mv.go @@ -51,44 +51,47 @@ func runCpMvOp(op string, paths ...string) { } pcs := GetBaiduPCS() + toFileName := path.Base(to) toInfo, pcsError := pcs.FilesDirectoriesMeta(to) - if pcsError != nil { - if pcsError.ErrorType() == baidupcs.ErrTypeRemoteError { - // 判断路径是否存在 - // 如果不存在, 则为重命名或同目录拷贝操作 + switch { + case toInfo != nil && toInfo.Filename != toFileName: + fallthrough + case pcsError != nil && pcsError.ErrorType() == baidupcs.ErrTypeRemoteError: + // 判断路径是否存在 + // 如果不存在, 则为重命名或同目录拷贝操作 + + // 如果 froms 数不是1, 则意义不明确. + if len(froms) != 1 { + fmt.Println(err) + return + } - // 如果 froms 数不是1, 则意义不明确. - if len(froms) != 1 { + if op == "copy" { // 拷贝 + err = pcs.Copy(&baidupcs.CpMvJSON{ + From: froms[0], + To: to, + }) + if err != nil { fmt.Println(err) + fmt.Println("文件/目录拷贝失败: ") + fmt.Printf("%s <-> %s\n", froms[0], to) return } - - if op == "copy" { // 拷贝 - err = pcs.Copy(&baidupcs.CpMvJSON{ - From: froms[0], - To: to, - }) - if err != nil { - fmt.Println(err) - fmt.Println("文件/目录拷贝失败: ") - fmt.Printf("%s <-> %s\n", froms[0], to) - return - } - fmt.Println("文件/目录拷贝成功: ") - fmt.Printf("%s <-> %s\n", froms[0], to) - } else { // 重命名 - err = pcs.Rename(froms[0], to) - if err != nil { - fmt.Println(err) - fmt.Println("重命名失败: ") - fmt.Printf("%s -> %s\n", froms[0], to) - return - } - fmt.Println("重命名成功: ") + fmt.Println("文件/目录拷贝成功: ") + fmt.Printf("%s <-> %s\n", froms[0], to) + } else { // 重命名 + err = pcs.Rename(froms[0], to) + if err != nil { + fmt.Println(err) + fmt.Println("重命名失败: ") fmt.Printf("%s -> %s\n", froms[0], to) + return } - return + fmt.Println("重命名成功: ") + fmt.Printf("%s -> %s\n", froms[0], to) } + return + case pcsError != nil && pcsError.ErrorType() != baidupcs.ErrTypeRemoteError: fmt.Println(pcsError) return } diff --git a/internal/pcscommand/download.go b/internal/pcscommand/download.go index dfb8ac2d..0a5370c0 100644 --- a/internal/pcscommand/download.go +++ b/internal/pcscommand/download.go @@ -405,7 +405,7 @@ func RunDownload(paths []string, options *DownloadOptions) { totalSize += task.downloadInfo.Size } - fmt.Fprintf(options.Out, "任务结束, 时间: %s, 数据总量: %s\n", time.Since(startTime), converter.ConvertFileSize(totalSize)) + fmt.Fprintf(options.Out, "任务结束, 时间: %s, 数据总量: %s\n", time.Since(startTime)/1e6*1e6, converter.ConvertFileSize(totalSize)) if len(failedList) != 0 { fmt.Printf("以下文件下载失败: \n") tb := pcstable.NewTable(os.Stdout) diff --git a/main.go b/main.go index 5a5016db..7adf8f37 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ import ( var ( // Version 版本号 - Version = "v3.5.2-devel" + Version = "v3.5.3-devel" historyFilePath = filepath.Join(pcsconfig.GetConfigDir(), "pcs_command_history.txt") reloadFn = func(c *cli.Context) error { diff --git a/requester/downloader/worker.go b/requester/downloader/worker.go index 949d85b9..707b0d06 100644 --- a/requester/downloader/worker.go +++ b/requester/downloader/worker.go @@ -233,7 +233,10 @@ func (wer *Worker) Execute() { } // 已完成 - if wer.wrange.Len() <= 0 { + if rlen := wer.wrange.Len(); rlen <= 0 { + if rlen < 0 { + pcsverbose.Verbosef("DEBUG: RangeLen is negative at begin: %v, %d\n", wer.wrange, wer.wrange.Len()) + } wer.status.statusCode = StatusCodeSuccessed return } @@ -394,16 +397,20 @@ func (wer *Worker) Execute() { } if readErr != nil { + rlen := wer.wrange.Len() switch { case single && readErr == io.ErrUnexpectedEOF: // 单线程判断下载成功 fallthrough case readErr == io.EOF: fallthrough - case wer.wrange.Len() <= 0: + case rlen <= 0: // 下载完成 // 小于0可能是因为 worker 被 duplicate wer.status.statusCode = StatusCodeSuccessed + if rlen < 0 { + pcsverbose.Verbosef("DEBUG: RangeLen is negative at end: %v, %d\n", wer.wrange, wer.wrange.Len()) + } return default: // 其他错误, 返回 diff --git a/resource_windows.syso b/resource_windows.syso index 210c92da..61d4bd1f 100644 Binary files a/resource_windows.syso and b/resource_windows.syso differ diff --git a/versioninfo.json b/versioninfo.json index c9247195..eb73c77d 100644 --- a/versioninfo.json +++ b/versioninfo.json @@ -3,13 +3,13 @@ "FileVersion": { "Major": 3, "Minor": 5, - "Patch": 2, + "Patch": 3, "Build": 0 }, "ProductVersion": { "Major": 3, "Minor": 5, - "Patch": 2, + "Patch": 3, "Build": 0 }, "FileFlagsMask": "3f", @@ -22,14 +22,14 @@ "Comments": "", "CompanyName": "iikira", "FileDescription": "百度网盘客户端", - "FileVersion": "v3.5.2", + "FileVersion": "v3.5.3", "InternalName": "", "LegalCopyright": "© 2016-2018 iikira.", "LegalTrademarks": "", "OriginalFilename": "", "PrivateBuild": "", "ProductName": "BaiduPCS-Go", - "ProductVersion": "v3.5.2", + "ProductVersion": "v3.5.3", "SpecialBuild": "" }, "VarFileInfo": {