def bulk_copy(fs_handle, source_path, dst_path, should_cancel):
"""
bulk copy data from source to destination -- only directories, symlinks
- and regular files are synced. note that @should_cancel is not used right
- now but would be required when implementing cancelation for in-progress
- clone operations.
+ and regular files are synced.
"""
log.info("copying data from {0} to {1}".format(source_path, dst_path))
def cptree(src_root_path, dst_root_path):
raise
elif stat.S_ISREG(stx["mode"]):
log.debug("cptree: (REG) {0}".format(d_full_src))
- copy_file(fs_handle, d_full_src, d_full_dst, mo)
+ copy_file(fs_handle, d_full_src, d_full_dst, mo, cancel_check=should_cancel)
else:
handled = False
log.warn("cptree: (IGNORE) {0}".format(d_full_src))
except cephfs.Error as e:
raise VolumeException(-e.args[0], e.args[1])
-def copy_file(fs, src, dst, mode):
+def copy_file(fs, src, dst, mode, cancel_check=None):
"""
Copy a regular file from @src to @dst. @dst is overwritten if it exists.
"""
IO_SIZE = 8 * 1024 * 1024
try:
while True:
+ if cancel_check and cancel_check():
+ raise VolumeException(-errno.EINTR, "copy operation interrupted")
data = fs.read(src_fd, -1, IO_SIZE)
if not len(data):
break