{"record":{"id":"5cbdb78eb4ecf7ad","repo":"AlistGo/alist","slug":"copy-merge-file-s-w","errorCode":null,"errorMessage":"copy merge file %s: %w","messagePattern":"copy merge file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/sjtu_netdisk/driver.go","lineNumber":527,"sourceCode":"\t\t\t\t\tchildObj := &model.Object{\n\t\t\t\t\t\tName:     child.GetName(),\n\t\t\t\t\t\tPath:     childSrcPath,\n\t\t\t\t\t\tSize:     child.GetSize(),\n\t\t\t\t\t\tIsFolder: true,\n\t\t\t\t\t}\n\t\t\t\t\tif _, mergeErr := d.Copy(ctx, childObj, targetDirObj); mergeErr != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"copy merge subfolder %s: %w\", child.GetName(), mergeErr)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tchildEncoded := d.encodePath(path.Join(targetPath, child.GetName()))\n\t\t\t\t\tchildURL := fmt.Sprintf(\"%s/file/%s/%s/%s\", API_URL, d.libraryId, d.spaceId, childEncoded)\n\t\t\t\t\tif _, fileErr := d.newClient().R().\n\t\t\t\t\t\tSetContext(ctx).\n\t\t\t\t\t\tSetQueryParam(\"access_token\", d.accessToken).\n\t\t\t\t\t\tSetQueryParam(\"conflict_resolution_strategy\", \"overwrite\").\n\t\t\t\t\t\tSetBody(map[string]interface{}{\"copyFrom\": childSrcPath}).\n\t\t\t\t\t\tExecute(http.MethodPut, childURL); fileErr != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"copy merge file %s: %w\", child.GetName(), fileErr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn &model.Object{\n\t\t\t\tName:     srcObj.GetName(),\n\t\t\t\tSize:     srcObj.GetSize(),\n\t\t\t\tIsFolder: true,\n\t\t\t\tModified: srcObj.ModTime(),\n\t\t\t\tCtime:    time.Now(),\n\t\t\t\tPath:     targetPath,\n\t\t\t}, nil\n\t\t}\n\n\t\t// 202 Accepted：polling task status\n\t\tif resp.StatusCode() != http.StatusAccepted {\n\t\t\treturn nil, fmt.Errorf(\"unexpected copy folder response: status=%d\", resp.StatusCode())\n\t\t}","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/sjtu_netdisk/driver.go#L509-L545","documentation":"During a copy-merge in the SJTU driver, copying one child FILE (a direct PUT /file/... with copyFrom and \"overwrite\" strategy) returned a transport-level error. The message names the file. Because conflicts are overwritten, any failure here is an API/transport problem, not a name clash.","triggerScenarios":"Copy folder onto an existing name; the per-file copy PUT fails (expired token, 5xx, connection reset during bulk operations).","commonSituations":"Bulk copies where one file failure aborts everything; network instability; server-side throttling during many rapid PUTs.","solutions":["Retry the parent copy — overwrite semantics make retries safe","Address the wrapped transport error (network, auth) first","Copy the named file alone to confirm it succeeds","Reduce batch size or add delay between large copies if throttled"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"copy merge file\") {\n    f := extractFileName(err)\n    return copySingleFile(ctx, f) // 'overwrite' makes retries safe\n}","preventionTips":["Retry the named file — overwrite semantics are idempotent","Stabilize network before bulk copies","Throttle large copies to avoid server-side rate limits"],"tags":["sjtu-netdisk","copy","merge","file"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}