feat: force file sync while uploading file (#5668)

This commit is contained in:
Jagadam Dinesh Reddy
2026-01-10 14:00:08 +05:30
committed by GitHub
parent 94ec786d34
commit 4fd18a382c
2 changed files with 12 additions and 0 deletions

View File

@@ -256,6 +256,12 @@ func tusPatchHandler() handleFunc {
return http.StatusInternalServerError, fmt.Errorf("could not write to file: %w", err)
}
// Sync the file to ensure all data is written to storage
// to prevent file corruption.
if err := openFile.Sync(); err != nil {
return http.StatusInternalServerError, fmt.Errorf("could not sync file: %w", err)
}
newOffset := uploadOffset + bytesWritten
w.Header().Set("Upload-Offset", strconv.FormatInt(newOffset, 10))