拖拽上传文件夹未读取全部文件修复
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
eefb42c3f6
commit
653d3c6228
|
|
@ -197,16 +197,32 @@ export function workSpeedclose(isForce = false) {
|
|||
imageId = null;
|
||||
percentageById = {};
|
||||
}
|
||||
function readDirectoryEntries(directoryReader) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let entries = [];
|
||||
function readBatch() {
|
||||
directoryReader.readEntries(
|
||||
(results) => {
|
||||
if (results.length) {
|
||||
entries = entries.concat(results);
|
||||
readBatch();
|
||||
} else {
|
||||
resolve(entries);
|
||||
}
|
||||
},
|
||||
(error) => reject(error)
|
||||
);
|
||||
}
|
||||
readBatch();
|
||||
});
|
||||
}
|
||||
export async function readEntry(entry) {
|
||||
const files = [];
|
||||
|
||||
// 如果是文件夹,创建读取器并递归读取其内容
|
||||
if (entry.isDirectory) {
|
||||
const directoryReader = entry.createReader();
|
||||
const entries = await new Promise((resolve, reject) => {
|
||||
directoryReader.readEntries(resolve, reject); // readEntries是异步的
|
||||
});
|
||||
|
||||
const entries = await readDirectoryEntries(directoryReader)
|
||||
// 递归读取文件夹内的每一项
|
||||
for (const subEntry of entries) {
|
||||
const subFiles = await readEntry(subEntry);
|
||||
|
|
|
|||
Loading…
Reference in New Issue