filestore: Do not error out on unexpected EOF

This commit is contained in:
Marius 2019-05-16 00:03:14 +02:00
parent 6de723ec8b
commit 0dd8efd606
1 changed files with 9 additions and 0 deletions

View File

@ -85,6 +85,15 @@ func (store FileStore) WriteChunk(id string, offset int64, src io.Reader) (int64
defer file.Close()
n, err := io.Copy(file, src)
// If the HTTP PATCH request gets interrupted in the middle (e.g. because
// the user wants to pause the upload), Go's net/http returns an io.ErrUnexpectedEOF.
// However, for FileStore it's not important whether the stream has ended
// on purpose or accidentally.
if err == io.ErrUnexpectedEOF {
err = nil
}
return n, err
}