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)
|
||||
}, LOG_DELAY)
|
||||
|
||||
do {
|
||||
while (same_levels.length) {
|
||||
await Promise.all(same_levels.map(async v => {
|
||||
const { name, id, parent } = v
|
||||
const target = mapping[parent] || root
|
||||
const new_folder = await limit(() => create_folder(name, target, service_account))
|
||||
count++
|
||||
mapping[id] = new_folder.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)
|
||||
try {
|
||||
const { name, id, parent } = v
|
||||
const target = mapping[parent] || root
|
||||
const new_folder = await limit(() => create_folder(name, target, service_account))
|
||||
count++
|
||||
mapping[id] = new_folder.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])
|
||||
same_levels = [].concat(...same_levels.map(v => folders.filter(vv => vv.parent === v.id)))
|
||||
} while (same_levels.length && (limit.activeCount || limit.pendingCount))
|
||||
}
|
||||
|
||||
clearInterval(loop)
|
||||
return mapping
|
||||
|
|
Loading…
Reference in New Issue