Skip to content

Commit 5917a6b

Browse files
author
Bojan Nikolic
committed
Handle if ENODATA error and some data already written
1 parent a09ff4d commit 5917a6b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/shutil.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ def _fastcopy_sendfile(fsrc, fdst):
214214
# ENODATA: In rare cases, sendfile() on Linux Lustre
215215
# returns ENODATA.
216216
_USE_CP_SENDFILE = False
217+
218+
dstpos = os.lseek(outfd, 0, os.SEEK_CUR)
219+
if dstpos > 0:
220+
# Some data has already been written but we use
221+
# sendfile in a mode that does not update the
222+
# input fd position when reading. Hence seek the
223+
# input fd to the correct position before falling
224+
# back on POSIX read/write method
225+
os.lseek(infd, dstpos, os.SEEK_SET)
226+
217227
raise _GiveupOnFastCopy(err)
218228

219229
if err.errno == errno.ENOSPC: # filesystem is full

0 commit comments

Comments
 (0)