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


##########
src/buildstream/utils.py:
##########
@@ -359,6 +359,18 @@ def sha256sum(filename: str) -> str:
     return h.hexdigest()
 
 
+try:
+    os.copy_file_range  # type: ignore[attr-defined] Requires Python 3.8 or 
newer
+except AttributeError:
+    _copy_file = lambda src, dest: shutil.copyfile(src, dest)
+else:
+    def _copy_file(src, dest):
+        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:
+                num_bytes -= os.copy_file_range(src_file.fileno(), 
dest_file.fileno(), num_bytes)

Review Comment:
   I wrote code to fallback during runtime when not supported.



-- 
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