This is an automated email from the ASF dual-hosted git repository.
Miretpl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 89b92c3221f Return 0 instead of None from FTPHook.get_size for empty
files (#76665)
89b92c3221f is described below
commit 89b92c3221f0abc6a7ad8e3998b945e8931b8d1d
Author: Pavan Nandi <[email protected]>
AuthorDate: Tue Nov 10 03:28:00 2026 +0530
Return 0 instead of None from FTPHook.get_size for empty files (#76665)
---
providers/ftp/src/airflow/providers/ftp/hooks/ftp.py | 2 +-
providers/ftp/tests/unit/ftp/hooks/test_ftp.py | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/providers/ftp/src/airflow/providers/ftp/hooks/ftp.py
b/providers/ftp/src/airflow/providers/ftp/hooks/ftp.py
index 14f3be0327d..2812681475b 100644
--- a/providers/ftp/src/airflow/providers/ftp/hooks/ftp.py
+++ b/providers/ftp/src/airflow/providers/ftp/hooks/ftp.py
@@ -294,7 +294,7 @@ class FTPHook(BaseHook):
"""
conn = self.get_conn()
size = conn.size(path)
- return int(size) if size else None
+ return int(size) if size is not None else None
def test_connection(self) -> tuple[bool, str]:
"""Test the FTP connection by calling path with directory."""
diff --git a/providers/ftp/tests/unit/ftp/hooks/test_ftp.py
b/providers/ftp/tests/unit/ftp/hooks/test_ftp.py
index 7f3aefbd932..079c46f6c3a 100644
--- a/providers/ftp/tests/unit/ftp/hooks/test_ftp.py
+++ b/providers/ftp/tests/unit/ftp/hooks/test_ftp.py
@@ -105,12 +105,13 @@ class TestFTPHook:
self.conn_mock.sendcmd.assert_called_once_with("MDTM " + path)
- def test_get_size(self):
- self.conn_mock.size.return_value = 1942
+ @pytest.mark.parametrize("size", [1942, 0, None], ids=["file",
"empty-file", "no-size-reply"])
+ def test_get_size(self, size):
+ self.conn_mock.size.return_value = size
path = "/path/file"
with fh.FTPHook() as ftp_hook:
- ftp_hook.get_size(path)
+ assert ftp_hook.get_size(path) == size
self.conn_mock.size.assert_called_once_with(path)