nanonyme commented on code in PR #1793:
URL: https://github.com/apache/buildstream/pull/1793#discussion_r1068490023


##########
src/buildstream/utils.py:
##########
@@ -357,6 +358,21 @@ def sha256sum(filename: str) -> str:
     return h.hexdigest()
 
 
+def copy_file_range(src, dest):
+    if not _USE_CP_FILE_RANGE:
+        return False
+    with open(src, "rb") as src_file, open(dest, "wb") as dest_file:
+        num_bytes = os.fstat(src_file.fileno()).st_size
+        while num_bytes > 0:
+            try:
+                num_bytes -= os.copy_file_range(src_file.fileno(), 
dest_file.fileno(), num_bytes)
+            except OSError as error:
+                if error.errno in (errno.ENOSYS, errno.EXDEV):
+                    return False

Review Comment:
   I can do that, sure.



##########
src/buildstream/utils.py:
##########
@@ -357,6 +358,21 @@ def sha256sum(filename: str) -> str:
     return h.hexdigest()
 
 
+def copy_file_range(src, dest):
+    if not _USE_CP_FILE_RANGE:
+        return False
+    with open(src, "rb") as src_file, open(dest, "wb") as dest_file:
+        num_bytes = os.fstat(src_file.fileno()).st_size
+        while num_bytes > 0:
+            try:
+                num_bytes -= os.copy_file_range(src_file.fileno(), 
dest_file.fileno(), num_bytes)

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to