We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d7fe0a6 commit 1f7bcbeCopy full SHA for 1f7bcbe
src/dvc_objects/fs/system.py
@@ -88,15 +88,28 @@ def reflink(src, dst):
88
FICLONE = 0x40049409
89
90
def reflink(src, dst):
91
+ src_fd = os.open(src, os.O_RDONLY)
92
+
93
+ try:
94
+ dst_fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
95
+ except OSError:
96
+ os.close(src_fd)
97
+ raise
98
99
try:
- with open(src, "rb") as s, open(dst, "wb+") as d:
- fcntl.ioctl(d.fileno(), FICLONE, s.fileno())
100
+ fcntl.ioctl(dst_fd, FICLONE, src_fd)
101
except OSError:
102
103
+ os.close(dst_fd)
104
105
os.unlink(dst)
106
107
pass
108
raise
109
+ else:
110
111
112
113
else:
114
115
0 commit comments