From 277e7f3e5692ea2b72ac05f0e3dc45f643cb48b9 Mon Sep 17 00:00:00 2001 From: masx200 Date: Sun, 9 Aug 2020 15:44:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/uploadfile.js | 14 +++++++++----- lib/uploadfile.ts | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/lib/uploadfile.js b/lib/uploadfile.js index ce9de3f..ad9701e 100644 --- a/lib/uploadfile.js +++ b/lib/uploadfile.js @@ -4,7 +4,6 @@ const fatalerror = [ const directfailure = [ "以下文件上传失败:", "全部上传完毕, 总大小: 0B", - "ms, 总大小: 0B", "打开上传未完成数据库错误:", ]; const retrymsg = [ @@ -29,17 +28,22 @@ export async function upload(file, destination) { try { result = await baidupcsupload(file, destination); } catch (error) { - const { stdout, stderr } = error; + const { stdout, stderr, code } = error; console.error(error); console.error(JSON.stringify({ stdout, stderr }, null, 4)); - if (typeof stdout !== "string" || typeof stderr !== "string") { + if ( + typeof code !== "number" || + typeof stdout !== "string" || + typeof stderr !== "string" + ) { throw error; } else if ( + code === 2 && !directfailure.some((m) => stdout.includes(m)) && successerror.some((m) => stderr?.includes(m)) && successmsg.some((m) => stdout?.includes(m)) ) { - console.log("文件上传成功", file, destination); + console.log("初步文件上传成功", file, destination); return; } else { throw error; @@ -55,7 +59,7 @@ export async function upload(file, destination) { console.warn("上传失败,5秒后重试:" + file); return await retryupload(file, destination); } else if (successmsg.some((m) => stdout.includes(m))) { - console.log("文件上传成功", file, destination); + console.log("初步文件上传成功", file, destination); return; } else if (retrymsg.some((msg) => stdout.includes(msg))) { console.warn(stdout, stderr); diff --git a/lib/uploadfile.ts b/lib/uploadfile.ts index 8231f62..1c049f4 100644 --- a/lib/uploadfile.ts +++ b/lib/uploadfile.ts @@ -7,10 +7,18 @@ const directfailure = [ "以下文件上传失败:", "全部上传完毕, 总大小: 0B", - "ms, 总大小: 0B", + // "ms, 总大小: 0B", "打开上传未完成数据库错误:", ]; +/* +[1] 加入上传队列: /sdcard/test/test/文件.txt +[1] 准备上传: /sdcard/test/test/文件.txt +[1] 目标文件, /我的测试/test/文件.txt, 已存在, 跳过... + +上传结束, 时间: 547ms, 总大小: 0B + +*/ const retrymsg = [ "网络错误, http 响应错误,", "遇到错误, 远端服务器返回错误, 代码: 31352, 消息: commit superfile2 failed", @@ -40,17 +48,43 @@ export async function upload(file: string, destination: string): Promise { try { result = await baidupcsupload(file, destination); } catch (error) { - const { stdout, stderr } = error; + const { stdout, stderr, code } = error; console.error(error); console.error(JSON.stringify({ stdout, stderr }, null, 4)); - if (typeof stdout !== "string" || typeof stderr !== "string") { + /* +Error: spawn BaiduPCS-Go ENOENT + at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19) + at onErrorNT (internal/child_process.js:468:16) + at processTicksAndRejections (internal/process/task_queues.js:84:21) { + errno: -2, + code: 'ENOENT', + syscall: 'spawn BaiduPCS-Go', + path: 'BaiduPCS-Go', + spawnargs: [ 'upload', '/sdcard/test/test/文件.txt', '/我 的测试/test' ], + cmd: 'BaiduPCS-Go upload /sdcard/test/test/文件.txt /我的 测试/test', + stdout: '', + stderr: '' +} + +*/ + + /* +Error: Command failed: BaiduPCS-Go.exe upload D:\baidupandownload\微博美图合集-2020-02-15+2020-02-14\图片压缩输出\微博美图合集-2020-02-14\教主Shadow\微博配图\882ab48745b65338f17c993f80d3f15c.webp /我的图片/微博美图合集-2020-02-15+2020-02-14/图片压缩输出/微博美图合集-2020-02-14/教主Shadow/微博配图 panic: runtime error: index out of range goroutine 22 [running]:github.com/iikira/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(*UploadingDatabase).UpdateUploading(0xc0422e48d0, 0xc042222240, 0xc0420f6ee0) /Users/syy/go/src/github.com/iikira/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:101 +0x279github.com/iikira/BaiduPCS-Go/internal/pcscommand.RunUpload.func2.1(0xa60d20, 0xc042580a80, 0xc04205c240) /Users/syy/go/src/github.com/iikira/BaiduPCS-Go/internal/pcscommand/upload.go:355 +0x385github.com/iikira/BaiduPCS-Go/requester/uploader.(*MultiUploader).uploadStatusEvent.func1(0xc04206aa90) /Users/syy/go/src/github.com/iikira/BaiduPCS-Go/requester/uploader/status.go:93 +0x1a1created by github.com/iikira/BaiduPCS-Go/requester/uploader.(*MultiUploader).uploadStatusEvent /Users/syy/go/src/github.com/iikira/BaiduPCS-Go/requester/uploader/status.go:84 +0x4f at ChildProcess.exithandler (child_process.js:303:12) at ChildProcess.emit (events.js:321:20) at maybeClose (internal/child_process.js:1026:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) { killed: false, code: 2, signal: null, cmd: 'BaiduPCS-Go.exe upload D:\\baidupandownload\\微博美图合集-2020-02-15+2020-02-14\\图片压缩输出\\微博美图合集-2020-02-14\\教主Shadow\\微博配图\\882ab48745b65338f17c993f80d3f15c.webp /我的图片/微博美图合集-2020-02-15+2020-02-14/图片压缩输出/微博美图合集-2020-02-14/教主Shadow/微博配图', + +*/ + if ( + typeof code !== "number" || + typeof stdout !== "string" || + typeof stderr !== "string" + ) { throw error; } else if ( + code === 2 && !directfailure.some((m) => stdout.includes(m)) && successerror.some((m) => stderr?.includes(m)) && successmsg.some((m) => stdout?.includes(m)) ) { - console.log("文件上传成功", file, destination); + console.log("初步文件上传成功", file, destination); return; } else { //如果。找不到 baidupcs-go的可执行文件,则。会在这里报错 @@ -79,7 +113,7 @@ export async function upload(file: string, destination: string): Promise { console.warn("上传失败,5秒后重试:" + file); return await retryupload(file, destination); } else if (successmsg.some((m) => stdout.includes(m))) { - console.log("文件上传成功", file, destination); + console.log("初步文件上传成功", file, destination); return; } else if (retrymsg.some((msg) => stdout.includes(msg))) { console.warn(stdout, stderr);