{"record":{"id":"2ebc96668855ac4b","repo":"dutchcoders/transfer.sh","slug":"cannot-reset-cache-file","errorCode":null,"errorMessage":"Cannot reset cache file","messagePattern":"Cannot reset cache file","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/handlers.go","lineNumber":660,"sourceCode":"\t\t\ts.logger.Printf(\"%s\", err.Error())\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\t// queue file to disk, because s3 needs content length\n\t\t// and clamav prescan scans a file\n\t\tn, err := io.Copy(file, r.Body)\n\t\tif err != nil {\n\t\t\ts.logger.Printf(\"%s\", err.Error())\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\n\t\t\treturn\n\t\t}\n\n\t\t_, err = file.Seek(0, io.SeekStart)\n\t\tif err != nil {\n\t\t\ts.logger.Printf(\"%s\", err.Error())\n\t\t\thttp.Error(w, \"Cannot reset cache file\", http.StatusInternalServerError)\n\n\t\t\treturn\n\t\t}\n\n\t\tcontentLength = n\n\n\t\tif s.performClamavPrescan {\n\t\t\tstatus, err := s.performScan(file.Name())\n\t\t\tif err != nil {\n\t\t\t\ts.logger.Printf(\"%s\", err.Error())\n\t\t\t\thttp.Error(w, \"Could not perform prescan\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif status != clamavScanStatusOK {\n\t\t\t\ts.logger.Printf(\"prescan positive: %s\", status)\n\t\t\t\thttp.Error(w, \"Clamav prescan found a virus\", http.StatusPreconditionFailed)\n\t\t\t\treturn","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/dutchcoders/transfer.sh/blob/c37bfd95797fd6da8a6da53fc13d191994b3f687/server/handlers.go#L642-L678","documentation":"After spooling the body to a temp file, putHandler seeks the file back to the start (file.Seek(0, io.SeekStart)) so it can be re-read for scanning and storage. If the seek fails, the server responds with 500 and this message. A seek on a regular local file essentially only fails on real OS-level I/O problems.","triggerScenarios":"file.Seek(0, io.SeekStart) returns an error — typically an underlying I/O error on the temp filesystem (failing disk), the file descriptor being invalid/closed, or exotic filesystems where seek is unsupported.","commonSituations":"Failing or overloaded disks in /tmp; containers using unusual storage drivers; running the temp path on a network/pipe-like filesystem that does not support seeking.","solutions":["Check the server log for the underlying seek error printed just before the response.","Move the temp path to a reliable local filesystem (not NFS/FUSE or a pipe).","Check disk health (dmesg / SMART) if the error indicates hardware I/O failure.","Restart the server to clear any invalid descriptors and retry the upload."],"exampleFix":"// before: temp dir on network storage\ntransfer --temp-path /mnt/nfs/tmp\n// after: use local disk\ntransfer --temp-path /var/tmp/transfer","handlingStrategy":"validation","validationCode":"// Operators: ensure temp path is on a seekable local filesystem\nfs := syscall.Statfs_t{}\nif err := syscall.Statfs(tempPath, &fs); err != nil {\n    log.Fatalf(\"temp path unavailable: %v\", err)\n}\n// verify it is not NFS/FUSE where seek can be unreliable\nif isNetworkFilesystem(tempPath) {\n    log.Fatal(\"temp path must be local disk\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := http.Put(url, mime, body)\nif err == nil && resp.StatusCode == 500 &&\n    strings.Contains(readBody(resp), \"Cannot reset cache file\") {\n    return fmt.Errorf(\"server temp filesystem failed seek; contact operator\")\n}","preventionTips":["Keep the temp path on local, healthy disk — not NFS, FUSE, or pipes.","Monitor disk SMART/IO errors on the temp volume.","Restart the server after filesystem errors to clear bad descriptors.","Retry the upload after the underlying I/O problem is resolved."],"tags":["filesystem","io","seek","temp-file","server"],"backgroundTag":"file-seek-failed","analyzedSha":"c37bfd95797fd6da8a6da53fc13d191994b3f687","analyzedAt":"2026-09-05T10:21:07.548Z","contentChangedAt":"2026-09-05T10:21:07.548Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}