Taragolis commented on code in PR #38373:
URL: https://github.com/apache/airflow/pull/38373#discussion_r1534015849


##########
airflow/providers/samba/hooks/samba.py:
##########
@@ -245,10 +245,22 @@ def setxattr(self, path, attribute, value, flags=0, 
follow_symlinks=True):
             **self._conn_kwargs,
         )
 
-    def push_from_local(self, destination_filepath: str, local_filepath: str):
-        """Push local file to samba server."""
-        with open(local_filepath, "rb") as f, 
self.open_file(destination_filepath, mode="wb") as g:
-            copyfileobj(f, g)
+    def push_from_local(self, destination_filepath: str, local_filepath: str, 
buffer_len: int | None = None):
+        """
+        Push local file to samba server.
+
+        :param destination_filepath: the samba location to push to
+        :param local_filepath: the file to push
+        :param buffer_len:
+            size in bytes of the individual chunks of file to send. Larger 
values may
+            speed up large file transfers
+        """
+        if buffer_len is not None:
+            with open(local_filepath, "rb") as f, 
self.open_file(destination_filepath, mode="wb") as g:
+                copyfileobj(f, g, buffer_len)
+        else:  # Use default buffer size for OS as determined by copyfileobj
+            with open(local_filepath, "rb") as f, 
self.open_file(destination_filepath, mode="wb") as g:
+                copyfileobj(f, g)

Review Comment:
   
[`shutil.copyfileobj`](https://docs.python.org/3/library/shutil.html#shutil.copyfileobj)
 always use buffer if length >= 0 (default 0) in case of 0 it fallback to 
platform specific value something like 16-64K for Linux.
   
   So I guess there is no need to create a condition if value provided or not, 
and just use
   `copyfileobj(f, g, buffer_len or 0)`



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to