🐛 Fix: multiple uploading in the same time will cause output conflict

ISSUES CLOSED: #666
This commit is contained in:
PiEgg
2021-05-09 10:52:14 +08:00
parent cf895deb8d
commit 06b67e50b9
4 changed files with 16 additions and 20 deletions

View File

@@ -109,19 +109,10 @@ class Uploader {
}
async upload (img?: IUploadOption): Promise<ImgInfo[]|false> {
// if (this.uploading) {
// showNotification({
// title: '上传失败',
// body: '前序上传还在继续,请稍后再试'
// })
// return Promise.resolve(false)
// }
try {
const startTime = Date.now()
// this.uploading = true
const output = await picgo.upload(img)
// this.uploading = false
if (Array.isArray(output) && output.every((item: ImgInfo) => item.imgUrl)) {
if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) {
if (this.webContents) {
handleTalkingData(this.webContents, {
fromClipboard: !img,
@@ -130,12 +121,11 @@ class Uploader {
duration: Date.now() - startTime
} as IAnalyticsData)
}
return output
return output.filter(item => item.imgUrl)
} else {
return false
}
} catch (e) {
// this.uploading = false
logger.error(e)
setTimeout(() => {
showNotification({