handle create folder fail

This commit is contained in:
Issue哥 2020-06-28 15:30:29 +08:00
parent ab004d9446
commit 6ee62fa6e0
1 changed files with 4 additions and 4 deletions

View File

@ -315,13 +315,12 @@ async function create_folder (name, parent, use_sa) {
mimeType: FOLDER_TYPE,
parents: [parent]
}
const headers = await gen_headers(use_sa)
const config = { headers }
let retry = 0
let data
while (!data && (retry < RETRY_LIMIT)) {
try {
data = (await axins.post(url, post_data, config)).data
const headers = await gen_headers(use_sa)
data = (await axins.post(url, post_data, { headers })).data
} catch (err) {
retry++
handle_error(err)
@ -542,7 +541,7 @@ async function create_folders ({ source, old_mapping, folders, root, task_id, se
console.log('================')
console.log('已创建的文件夹数量', count)
console.log('正在进行的网络请求', limit.activeCount)
console.log('排队等候的目录数量', limit.pendingCount)
console.log('排队等候的网络请求', limit.pendingCount)
}, LOG_DELAY)
while (same_levels.length) {
@ -551,6 +550,7 @@ async function create_folders ({ source, old_mapping, folders, root, task_id, se
const { name, id, parent } = v
const target = mapping[parent] || root
const new_folder = await limit(() => create_folder(name, target, service_account))
if (!new_folder) throw new Error(name + '创建失败')
count++
mapping[id] = new_folder.id
const mapping_record = id + ' ' + new_folder.id + '\n'