{"record":{"id":"682c68cbc9004d0a","repo":"AlistGo/alist","slug":"existing-file-not-found","errorCode":null,"errorMessage":"existing file not found","messagePattern":"existing file not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"drivers/mediafire/util.go","lineNumber":600,"sourceCode":"\nfunc (d *Mediafire) getExistingFileInfo(ctx context.Context, fileHash, filename, folderKey string) (*model.ObjThumb, error) {\n\n\tif fileInfo, err := d.getFileByHash(ctx, fileHash); err == nil && fileInfo != nil {\n\t\treturn fileInfo, nil\n\t}\n\n\tfiles, err := d.getFiles(ctx, folderKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, file := range files {\n\t\tif file.Name == filename && !file.IsFolder {\n\t\t\treturn d.fileToObj(file), nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"existing file not found\")\n}\n\nfunc (d *Mediafire) getFileByHash(_ context.Context, hash string) (*model.ObjThumb, error) {\n\tquery := map[string]string{\n\t\t\"session_token\":   d.SessionToken,\n\t\t\"response_format\": \"json\",\n\t\t\"hash\":            hash,\n\t}\n\n\tvar resp MediafireFileSearchResponse\n\t_, err := d.postForm(\"/file/get_info.php\", query, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.Response.Result != \"Success\" {\n\t\treturn nil, fmt.Errorf(\"MediaFire file search failed: %s\", resp.Response.Result)\n\t}","sourceCodeStart":582,"sourceCodeEnd":618,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/mediafire/util.go#L582-L618","documentation":"A linear scan of the folder listing completed without any non-folder entry whose Name equals the requested filename. This is a lookup-miss on an exact, case-sensitive name match, used to find an existing file (typically before upload to decide update-vs-create). The folder itself was listed successfully; the file simply is not there under that exact name.","triggerScenarios":"First upload of a file with this name (expected miss); filename differs by case, trailing space, or Unicode normalization; file in a subfolder rather than the scanned folder; listing pagination missing entries; file deleted between operations.","commonSituations":"Upload flows calling findExisting before Put; case-sensitivity surprises when the file was created with different casing on another OS; NFD vs NFC Unicode names from macOS clients; files moved to trash and thus excluded from the listing.","solutions":["Treat as not-found and proceed with create/new-upload logic rather than erroring — this is a normal miss in find-or-create flows","If the file should exist, list the folder and compare names byte-for-byte (check case and Unicode normalization)","Confirm the correct folderKey is being scanned","Check MediaFire trash — deleted files are absent from folder listings"],"exampleFix":"// before\nfor _, file := range files {\n    if file.Name == filename && !file.IsFolder {\n        return d.fileToObj(file), nil\n    }\n}\nreturn nil, fmt.Errorf(\"existing file not found\")\n\n// after (caller treats not-found as non-fatal)\nexisting, err := d.findExisting(ctx, folderKey, filename)\nif err != nil {\n    if strings.Contains(err.Error(), \"existing file not found\") {\n        existing = nil // proceed with fresh upload\n    } else {\n        return err\n    }\n}","handlingStrategy":"validation","validationCode":"// Normalize before comparing names\nwant := strings.TrimSpace(filename)\nfor _, f := range files {\n    if !f.IsFolder && norm.NFC.String(f.Name) == norm.NFC.String(want) {\n        return d.fileToObj(f), nil\n    }\n}","typeGuard":null,"tryCatchPattern":"// find-or-create: not-found is a branch, not a failure\nexisting, err := d.findExisting(ctx, folder, name)\nif err != nil && strings.Contains(err.Error(), \"existing file not found\") {\n    existing = nil\n} else if err != nil {\n    return err\n}","preventionTips":["Treat this error as the normal miss in upload flows","Use Unicode NFC normalization and exact-case comparison consciously","Scan the right folderKey; check trash for 'missing' files"],"tags":["mediafire","not-found","lookup","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}