拖拽上传文件夹未读取全部文件修复
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;
|
imageId = null;
|
||||||
percentageById = {};
|
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) {
|
export async function readEntry(entry) {
|
||||||
const files = [];
|
const files = [];
|
||||||
|
|
||||||
// 如果是文件夹,创建读取器并递归读取其内容
|
// 如果是文件夹,创建读取器并递归读取其内容
|
||||||
if (entry.isDirectory) {
|
if (entry.isDirectory) {
|
||||||
const directoryReader = entry.createReader();
|
const directoryReader = entry.createReader();
|
||||||
const entries = await new Promise((resolve, reject) => {
|
const entries = await readDirectoryEntries(directoryReader)
|
||||||
directoryReader.readEntries(resolve, reject); // readEntries是异步的
|
|
||||||
});
|
|
||||||
|
|
||||||
// 递归读取文件夹内的每一项
|
// 递归读取文件夹内的每一项
|
||||||
for (const subEntry of entries) {
|
for (const subEntry of entries) {
|
||||||
const subFiles = await readEntry(subEntry);
|
const subFiles = await readEntry(subEntry);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue