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
extra_args = (buffer_len, ) if buffer_len else tuple()
with open(local_filepath, "rb") as f, self.open_file(destination_filepath,
mode="wb") as g:
copyfileobj(f, b, *extra_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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]