{"record":{"id":"26e955155970fefc","repo":"AlistGo/alist","slug":"failed-to-create-direct-link-w","errorCode":null,"errorMessage":"failed to create direct link: %w","messagePattern":"failed to create direct link: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/gofile/driver.go","lineNumber":98,"sourceCode":"\t\tcontents = response.Data.Contents\n\t}\n\n\tfor _, content := range contents {\n\t\tobjects = append(objects, d.convertContentToObj(content))\n\t}\n\n\treturn objects, nil\n}\n\nfunc (d *Gofile) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error) {\n\tif file.IsDir() {\n\t\treturn nil, errs.NotFile\n\t}\n\n\t// Create a direct link for the file\n\tdirectLink, err := d.createDirectLink(ctx, file.GetID())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create direct link: %w\", err)\n\t}\n\n\t// Configure cache expiration based on user setting\n\tlink := &model.Link{\n\t\tURL: directLink,\n\t}\n\n\t// Only set expiration if LinkExpiry > 0 (0 means no caching)\n\tif d.LinkExpiry > 0 {\n\t\texpiration := time.Duration(d.LinkExpiry) * 24 * time.Hour\n\t\tlink.Expiration = &expiration\n\t}\n\n\treturn link, nil\n}\n\nfunc (d *Gofile) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error) {\n\tvar parentId string","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/gofile/driver.go#L80-L116","documentation":"Returned from Gofile Link when createDirectLink fails for a file ID. Gofile requires fetching a server-specific download link (and often a guest/host account token) per file; any failure in that flow is wrapped as 'failed to create direct link: <cause>'.","triggerScenarios":"Opening/downloading a file (Link call) where the Gofile 'contents' download endpoint errors: file deleted, server assignment failing, rate limit, invalid/expired website token, or network failure.","commonSituations":"File removed upstream but listing cache still shows it; Gofile server rotation invalidating cached links; heavy download traffic hitting Gofile rate limits; expired token used for link creation.","solutions":["Read the wrapped cause: 'gofile API error: ...' identifies the upstream reason (not-found, rate-limit)","Refresh the directory listing to drop deleted files, then retry the download","If rate-limited, back off and reduce parallel downloads from Gofile mounts","Re-init the driver storage so tokens/server info are re-fetched"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"link, err := d.Link(ctx, file, args)\nif err != nil {\n  if strings.Contains(err.Error(), \"failed to create direct link\") {\n    // invalidate cached listing for the parent and retry once\n  }\n}","preventionTips":["Expire cached Gofile listings quickly since upstream deletions invalidate links","Limit concurrent downloads to avoid upstream rate limits"],"tags":["gofile","download","link","network"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}