dutchcoders/transfer.sh · error
Cannot reset cache file
Error message
Cannot reset cache file
What it means
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.
Source
Thrown at server/handlers.go:660
s.logger.Printf("%s", err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// queue file to disk, because s3 needs content length
// and clamav prescan scans a file
n, err := io.Copy(file, r.Body)
if err != nil {
s.logger.Printf("%s", err.Error())
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = file.Seek(0, io.SeekStart)
if err != nil {
s.logger.Printf("%s", err.Error())
http.Error(w, "Cannot reset cache file", http.StatusInternalServerError)
return
}
contentLength = n
if s.performClamavPrescan {
status, err := s.performScan(file.Name())
if err != nil {
s.logger.Printf("%s", err.Error())
http.Error(w, "Could not perform prescan", http.StatusInternalServerError)
return
}
if status != clamavScanStatusOK {
s.logger.Printf("prescan positive: %s", status)
http.Error(w, "Clamav prescan found a virus", http.StatusPreconditionFailed)
returnView on GitHub (pinned to c37bfd9579)
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.
Example fix
// before: temp dir on network storage transfer --temp-path /mnt/nfs/tmp // after: use local disk transfer --temp-path /var/tmp/transfer
Defensive patterns
Strategy: validation
Validate before calling
// Operators: ensure temp path is on a seekable local filesystem
fs := syscall.Statfs_t{}
if err := syscall.Statfs(tempPath, &fs); err != nil {
log.Fatalf("temp path unavailable: %v", err)
}
// verify it is not NFS/FUSE where seek can be unreliable
if isNetworkFilesystem(tempPath) {
log.Fatal("temp path must be local disk")
} Try / catch
resp, err := http.Put(url, mime, body)
if err == nil && resp.StatusCode == 500 &&
strings.Contains(readBody(resp), "Cannot reset cache file") {
return fmt.Errorf("server temp filesystem failed seek; contact operator")
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Clamav prescan found a virus
- Could not encode metadata
- Could not save metadata
- Could not crypt file
- Could not retrieve file.
AI-assisted analysis of dutchcoders/transfer.sh@c37bfd9579 (2026-09-05).
Data as JSON: /api/errors/2ebc96668855ac4b.
Report an issue: GitHub.