try catch create_folder

This commit is contained in:
Issue哥 2020-06-28 08:17:02 +08:00
parent cb37371c85
commit ab004d9446
1 changed files with 13 additions and 9 deletions

View File

@ -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