mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-31 10:09:43 +08:00
🐛 Fix: multiple uploading in the same time will cause output conflict
ISSUES CLOSED: #666
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -5,6 +5,12 @@ import {
|
||||
import logger from '@core/picgo/logger'
|
||||
import windowManager from 'apis/app/window/windowManager'
|
||||
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||
import { app } from 'electron'
|
||||
import path from 'path'
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const LOG_PATH = path.join(STORE_PATH, 'picgo.log')
|
||||
|
||||
const errorMessage = `upload error. see ${LOG_PATH} for more detail.`
|
||||
|
||||
router.post('/upload', async ({
|
||||
response,
|
||||
@@ -31,7 +37,7 @@ router.post('/upload', async ({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'upload error'
|
||||
message: errorMessage
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -58,7 +64,7 @@ router.post('/upload', async ({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'upload error'
|
||||
message: errorMessage
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -69,7 +75,7 @@ router.post('/upload', async ({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: err
|
||||
message: errorMessage
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user