MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / rclone_api_post_async

Function rclone_api_post_async

src/utils/rclone/request.ts:219–241  ·  view source on GitHub ↗

* 启动异步任务 * @param path API 路径 * @param bodyData 请求体数据 * @param ignoreError 是否忽略错误 * @returns 返回 jobid 或 undefined

(
  path: string,
  bodyData: object = {},
  ignoreError?: boolean
)

Source from the content-addressed store, hash-verified

217 * @returns 返回 jobid 或 undefined
218 */
219async function rclone_api_post_async(
220 path: string,
221 bodyData: object = {},
222 ignoreError?: boolean
223): Promise<number | undefined> {
224 const fullPath = buildApiUrl(path)
225
226 try {
227 const res = await fetch(fullPath, {
228 method: 'POST',
229 headers: getRcloneApiHeaders(),
230 body: JSON.stringify({ ...bodyData, _async: true }),
231 })
232
233 const data = await handleApiResponse(res, fullPath, 'POST')
234 return (data as AsyncJobResponse)?.jobid
235 } catch (error) {
236 if (!ignoreError) {
237 await printError(error as Error | Response)
238 }
239 return undefined
240 }
241}
242
243/**
244 * 查询任务状态

Callers 1

rclone_api_exec_asyncFunction · 0.85

Calls 4

buildApiUrlFunction · 0.85
getRcloneApiHeadersFunction · 0.85
printErrorFunction · 0.85
handleApiResponseFunction · 0.70

Tested by

no test coverage detected