From 41afec220bb2dd7998254ff5b9832976c2831890 Mon Sep 17 00:00:00 2001 From: Dmitrii Metelkin Date: Fri, 11 Aug 2023 11:32:56 +1000 Subject: [PATCH] fix: properly handle limit in directory_file_list_trait --- classes/local/step/directory_file_list_trait.php | 1 + tests/tool_dataflows_sftp_test.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/classes/local/step/directory_file_list_trait.php b/classes/local/step/directory_file_list_trait.php index 413da57f..c9bd4e64 100644 --- a/classes/local/step/directory_file_list_trait.php +++ b/classes/local/step/directory_file_list_trait.php @@ -252,6 +252,7 @@ function ($filename) use ($basepath) { $func($filelist); + $limit = empty($limit) ? null : $limit; // Apply the offset and limit. $filelist = array_slice($filelist, $offset, $limit); diff --git a/tests/tool_dataflows_sftp_test.php b/tests/tool_dataflows_sftp_test.php index 04786f3a..ba74b6f6 100644 --- a/tests/tool_dataflows_sftp_test.php +++ b/tests/tool_dataflows_sftp_test.php @@ -99,6 +99,16 @@ public function sftp_list_constraints_provider(): array { 'test.csv', ], ], + [ + ['relativepath', 'alpha', 0, 0, false, '', '*.csv'], + [ + '2019-08-03-123451001.csv', + '2019-08-03-123451002.csv', + '2019-08-03-123451003.csv', + 'output/2019-08-03-123451002-final.csv', + 'test.csv', + ], + ], [ ['relativepath', 'alpha_reverse', 0, 1, false, '', '*.csv'], ['test.csv'],