try catch create_folder
This commit is contained in:
parent
cb37371c85
commit
ab004d9446
22
src/gd.js
22
src/gd.js
|
@ -545,19 +545,23 @@ async function create_folders ({ source, old_mapping, folders, root, task_id, se
|
||||||
console.log('排队等候的目录数量', limit.pendingCount)
|
console.log('排队等候的目录数量', limit.pendingCount)
|
||||||
}, LOG_DELAY)
|
}, LOG_DELAY)
|
||||||
|
|
||||||
do {
|
while (same_levels.length) {
|
||||||
await Promise.all(same_levels.map(async v => {
|
await Promise.all(same_levels.map(async v => {
|
||||||
const { name, id, parent } = v
|
try {
|
||||||
const target = mapping[parent] || root
|
const { name, id, parent } = v
|
||||||
const new_folder = await limit(() => create_folder(name, target, service_account))
|
const target = mapping[parent] || root
|
||||||
count++
|
const new_folder = await limit(() => create_folder(name, target, service_account))
|
||||||
mapping[id] = new_folder.id
|
count++
|
||||||
const mapping_record = id + ' ' + new_folder.id + '\n'
|
mapping[id] = new_folder.id
|
||||||
db.prepare('update task set status=?, mapping = mapping || ? where id=?').run('copying', mapping_record, task_id)
|
const mapping_record = id + ' ' + new_folder.id + '\n'
|
||||||
|
db.prepare('update task set status=?, mapping = mapping || ? where id=?').run('copying', mapping_record, task_id)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('创建目录出错:', v, e)
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
folders = folders.filter(v => !mapping[v.id])
|
folders = folders.filter(v => !mapping[v.id])
|
||||||
same_levels = [].concat(...same_levels.map(v => folders.filter(vv => vv.parent === v.id)))
|
same_levels = [].concat(...same_levels.map(v => folders.filter(vv => vv.parent === v.id)))
|
||||||
} while (same_levels.length && (limit.activeCount || limit.pendingCount))
|
}
|
||||||
|
|
||||||
clearInterval(loop)
|
clearInterval(loop)
|
||||||
return mapping
|
return mapping
|
||||||
|
|
Loading…
Reference in New Issue