Skip to content

Commit 2bf1ed9

Browse files
committed
🐛 Fix: the order of the uploaded list may not be the same as the order entered
ISSUES CLOSED: #40
1 parent 50a4842 commit 2bf1ed9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/plugins/transformer/path.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IPathTransformedImgInfo, ImgInfo, ImgSize } from '../../utils/interface
99

1010
const handle = async (ctx: PicGo): Promise<PicGo> => {
1111
let results: ImgInfo[] = ctx.output
12-
await Promise.all(ctx.input.map(async (item: string) => {
12+
await Promise.all(ctx.input.map(async (item: string, index: number) => {
1313
let info: IPathTransformedImgInfo
1414
if (isUrl(item)) {
1515
info = await getURLFile(item)
@@ -19,20 +19,22 @@ const handle = async (ctx: PicGo): Promise<PicGo> => {
1919
if (info.success) {
2020
try {
2121
const imgSize = getImgSize(ctx, info.buffer, item)
22-
results.push({
22+
results[index] = {
2323
buffer: info.buffer,
2424
fileName: info.fileName,
2525
width: imgSize.width,
2626
height: imgSize.height,
2727
extname: info.extname
28-
})
28+
}
2929
} catch (e) {
3030
ctx.log.error(e)
3131
}
3232
} else {
3333
ctx.log.error(info.reason)
3434
}
3535
}))
36+
// remove empty item
37+
ctx.output = results.filter(item => item)
3638
return ctx
3739
}
3840

0 commit comments

Comments
 (0)