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


##########
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:
   or if you want to keep conditional, e.g. prevent some changes in the future 
into the https://github.com/python/cpython/blob/main/Lib/shutil.py, you might 
make arguments by condition, e.g.
   
   ```python
   args = (f, g, buffer_len) if buffer_len else (f, g)
   with open(local_filepath, "rb") as f, self.open_file(destination_filepath, 
mode="wb") as g:
       copyfileobj(*args)
   ```



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