Molunerfinn / PicGo

:rocket:A simple & beautiful tool for pictures uploading built by vue-cli-electron-builder
https://molunerfinn.com/PicGo/
MIT License
24.2k stars 2.24k forks source link

[Bug]: 上传文件和原文件不一致 #1202

Closed DAODEJI closed 12 months ago

DAODEJI commented 12 months ago

前置阅读 | Pre-reading

PicGo的版本 | PicGo Version

v2.3.1

系统信息 | System Information

Windows

问题重现 | Bug reproduce

作者您好,我这边使用PicGo发现上传的文件和原文件不一致。 根据日志显示: 2023-11-25 17:36:13 [PicGo SUCCESS] https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png 第一次成功上传文件到腾讯云COS 但紧接着PicGo又获取到一次上传任务 2023-11-25 17:36:17 [PicGo INFO] [PicGo Server] get the request {"list":["https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png"]} 很明显这不是我自己发起的任务,而且使用的是url上传,不是本地路径,然后将第一次文件给替换掉了,导致我无法访问我的图片。

以下是我和腾讯云COS工程师的工单,部分内容敏感信息已经隐藏

腾讯云工程师2023-11-27 14:52:32 您好,这边再次通过image-20231125173613118.png文件的上传日志分析发现: 11-25 17:36:14.696 上传了一次,上传大小是223771字节(正常文件) 然后5秒后: 11-25 17:36:19.515又上传了一个同名文件,文件大小是405751字节(异常文件)----在这之后访问的话就异常了 而今天: 11-27 11:48:37.132 又上传了一次,上传大小是223771字节(正常文件) ---这之后访问的就正常了

11-25 17:36:19.515上传的请求记录如下: 请求数据: 用户 IP: ...

PUT http://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag.%2Fimage-20231125173613118.png Headers: accept: application/json, text/plain, / authorization: connection: close content-length: 405232 content-type: image/png host: pico-1310471790.cos.ap-chengdu.myqcloud.com useragent: PicGo;2.3.1-beta.6;null;null user-agent: axios/0.27.2

您可以检查看下上传逻辑。看是不是存在这种情况:在正常上传后,过了数秒又发起一次上传,此时上传了一个较大的异常文件。

腾讯云工程师2023-11-27 17:09:54 您好,这边看了您提供的日志记录。看上去像是上传了两次。但是这边不理解PicGo的处理逻辑。

就COS服务端角度,可以多次上传同名文件,COS并未有此限制。 对于未开启多版本的场景,上传同名文件会将之前上传的文件覆盖掉。结合您场景,就是新上传的覆盖掉之前上传的。所以出现了异常。 您可以从插件或者业务逻辑上看下能否避免类似情况。

相关日志 | Logs

2023-11-25 17:36:13 [PicGo INFO] [PicGo Server] get the request {"list":["C:\Users\daode\AppData\Roaming\Typora\typora-user-images\image-20231125173613118.png"]} 2023-11-25 17:36:13 [PicGo INFO] [PicGo Server] upload files in list 2023-11-25 17:36:13 [PicGo INFO] Before transform 2023-11-25 17:36:13 [PicGo INFO] Transforming... Current transformer is [path] 2023-11-25 17:36:13 [PicGo INFO] Before upload 2023-11-25 17:36:13 [PicGo INFO] beforeUploadPlugins: renameFn running 2023-11-25 17:36:13 [PicGo INFO] Uploading... Current uploader is [tcyun] 2023-11-25 17:36:13 [PicGo SUCCESS] https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png 2023-11-25 17:36:13 [PicGo INFO] [PicGo Server] upload result https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png 2023-11-25 17:36:17 [PicGo INFO] [PicGo Server] get the request {"list":["https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png"]} 2023-11-25 17:36:17 [PicGo INFO] [PicGo Server] upload files in list 2023-11-25 17:36:17 [PicGo INFO] Before transform 2023-11-25 17:36:17 [PicGo INFO] Transforming... Current transformer is [path] 2023-11-25 17:36:18 [PicGo WARN] can't get https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png's image size 2023-11-25 17:36:18 [PicGo WARN] fallback to 200 * 200 2023-11-25 17:36:18 [PicGo INFO] Before upload 2023-11-25 17:36:18 [PicGo INFO] beforeUploadPlugins: renameFn running 2023-11-25 17:36:18 [PicGo INFO] Uploading... Current uploader is [tcyun] 2023-11-25 17:36:18 [PicGo SUCCESS] https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png 2023-11-25 17:36:18 [PicGo INFO] [PicGo Server] upload result https://pico-1310471790.cos.ap-chengdu.myqcloud.com/imag./image-20231125173613118.png

Molunerfinn commented 12 months ago

使用 url 上传说明你使用了类似 typora 等工具通过 http 调用 picgo 上传。请自行检查对应工具的行为,picgo不会主动发起上传请求。