qjfoidnh / BaiduPCS-Go

iikira/BaiduPCS-Go原版基础上集成了分享链接/秒传链接转存功能
Apache License 2.0
3k stars 453 forks source link

将文件上传到百度云出错,out of range #244

Closed Ted-bug closed 1 year ago

Ted-bug commented 1 year ago

panic: runtime error: slice bounds out of range [1:0]

goroutine 9 [running]: github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).deleteIndex(...) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:116 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).clearModTimeChange(0xa2a4fd8) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:183 +0x4cb github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).Search(0xa2a4fd8, 0xa0c8f00, 0xa2d8480) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:145 +0x39 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).prepareFile(0xa0c8f50) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:77 +0xca github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).Run(0xa0c8f50, 0x0) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:356 +0x1dc github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(TaskExecutor).Execute.func1(0xa2b5080, 0xa2c8f18, 0xa2c4d10) /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:94 +0x54 created by github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(*TaskExecutor).Execute /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:91 +0x68 panic: runtime error: slice bounds out of range [1:0]

goroutine 6 [running]: github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).deleteIndex(...) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:116 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).clearModTimeChange(0xa2a4fd8) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:183 +0x4cb github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).Search(0xa2a4fd8, 0xa0c8d20, 0xa2d8000) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:145 +0x39 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).prepareFile(0xa0c8d70) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:77 +0xca github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).Run(0xa0c8d70, 0x0) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:356 +0x1dc github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(TaskExecutor).Execute.func1(0xa2b5080, 0xa2c8f18, 0xa2c4cb0) /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:94 +0x54 created by github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(*TaskExecutor).Execute /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:91 +0x68 panic: runtime error: slice bounds out of range [1:0]

goroutine 8 [running]: github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).deleteIndex(...) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:116 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).clearModTimeChange(0xa2a4fd8) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:183 +0x4cb github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadingDatabase).Search(0xa2a4fd8, 0xa0c8e60, 0xa2d8300) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_database.go:145 +0x39 github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).prepareFile(0xa0c8eb0) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:77 +0xca github.com/qjfoidnh/BaiduPCS-Go/internal/pcsfunctions/pcsupload.(UploadTaskUnit).Run(0xa0c8eb0, 0x0) /home/liu/Projects/BaiduPCS-Go/internal/pcsfunctions/pcsupload/upload_task_unit.go:356 +0x1dc github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(TaskExecutor).Execute.func1(0xa2b5080, 0xa2c8f18, 0xa2c4cf0) /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:94 +0x54 created by github.com/qjfoidnh/BaiduPCS-Go/pcsutil/taskframework.(*TaskExecutor).Execute /home/liu/Projects/BaiduPCS-Go/pcsutil/taskframework/executor.go:91 +0x68

Ted-bug commented 1 year ago

OD26WMIB0`5_A`XSLMCE{O7 图中我加了点自定义的输出信息,可以发现:文件夹上传时,读取了两次pcs_uploading.json中获取到的信息(代码中并发上传文件,共用database)。 当获取到的上传中文件路径不存在时,会执行切片删除元素操作,此时便会出错。 解决方式:手动删除pcs_uploading.json文件,或者更换使用为线程安全的sync.Map