Skip to content

Commit

Permalink
🐛 Fix: the order of the uploaded list may not be the same as the orde…
Browse files Browse the repository at this point in the history
…r entered

ISSUES CLOSED: #40
  • Loading branch information
Molunerfinn committed Jun 25, 2020
1 parent 50a4842 commit 2bf1ed9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/plugins/transformer/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IPathTransformedImgInfo, ImgInfo, ImgSize } from '../../utils/interface

const handle = async (ctx: PicGo): Promise<PicGo> => {
let results: ImgInfo[] = ctx.output
await Promise.all(ctx.input.map(async (item: string) => {
await Promise.all(ctx.input.map(async (item: string, index: number) => {
let info: IPathTransformedImgInfo
if (isUrl(item)) {
info = await getURLFile(item)
Expand All @@ -19,20 +19,22 @@ const handle = async (ctx: PicGo): Promise<PicGo> => {
if (info.success) {
try {
const imgSize = getImgSize(ctx, info.buffer, item)
results.push({
results[index] = {
buffer: info.buffer,
fileName: info.fileName,
width: imgSize.width,
height: imgSize.height,
extname: info.extname
})
}
} catch (e) {
ctx.log.error(e)
}
} else {
ctx.log.error(info.reason)
}
}))
// remove empty item
ctx.output = results.filter(item => item)
return ctx
}

Expand Down

0 comments on commit 2bf1ed9

Please sign in to comment.