-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: upload drag directory can not work #562
fix: upload drag directory can not work #562
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -76,11 +76,11 @@ class AjaxUploader extends Component<UploadProps> { | |||
} | |||
|
|||
if (this.props.directory) { | |||
traverseFileTree( | |||
const files = await traverseFileTree( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加个 test 吧~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尝试加了一个-。-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啥时候能发版啊。。。。。。
src/traverseFileTree.ts
Outdated
} | ||
while (true) { | ||
const results = await new Promise<InternalDataTransferItem[]>((resolve, reject) => { | ||
dirReader.readEntries(resolve, reject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按照原本的逻辑,失败了就直接无视了。这里加了 reject 后,没有做错误处理,await 后会直接挂掉。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zombieJ 更新了下这块的处理,看看有没有问题
src/traverseFileTree.ts
Outdated
break; | ||
} | ||
|
||
for (const entry of results) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个换一下 for (let i ...)
,IE 11 不支持 of loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zombieJ 已更新
fix ant-design/ant-design#50080
upload/src/traverseFileTree.ts
Lines 20 to 31 in 80e5228
出现这个bug的原因大概率是因为异步api导致,
dirReader.readEntries
是异步且被递归调用,walkFiles
这个方法又是同步执行的,while循环结束了一会之后才会走入readEntries
的回调,导致callback
其实是提前拿了一个空数组就提前结束。