This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 4d57dcc406 Fix#9170  FTP get/delete: setup failures stay false under 
Nr errors at most (#9187)
4d57dcc406 is described below

commit 4d57dcc4067b723582b8907b8ea50e08e5d1cc6e
Author: Lance <[email protected]>
AuthorDate: Mon Nov 2 22:12:23 2026 +0800

    Fix#9170  FTP get/delete: setup failures stay false under Nr errors at most 
(#9187)
    
    * FTP get/delete: setup failures stay false under Nr errors at most
    
    Signed-off-by: leehaut <[email protected]>
    
    * FTP get/delete: setup failures stay false under Nr errors at most
    
    Signed-off-by: leehaut <[email protected]>
    
    * remove incorrect translations after key change
    
    ---------
    
    Signed-off-by: leehaut <[email protected]>
    Co-authored-by: Hans Van Akelyen <[email protected]>
---
 .../modules/ROOT/pages/workflow/actions/ftp.adoc   |   6 +-
 .../ROOT/pages/workflow/actions/ftpdelete.adoc     |   6 +-
 .../apache/hop/workflow/actions/ftp/ActionFtp.java |  21 ++-
 .../actions/ftpdelete/ActionFtpDelete.java         |  25 ++-
 .../actions/ftp/messages/messages_en_US.properties |   2 +-
 .../actions/ftp/messages/messages_es_AR.properties |   1 -
 .../actions/ftp/messages/messages_fr_FR.properties |   1 -
 .../actions/ftp/messages/messages_it_IT.properties |   1 -
 .../actions/ftp/messages/messages_ko_KR.properties |   1 -
 .../actions/ftp/messages/messages_pt_BR.properties |   1 -
 .../actions/ftp/messages/messages_zh_CN.properties |   2 +-
 .../ftpdelete/messages/messages_en_US.properties   |   2 +-
 .../ftpdelete/messages/messages_es_AR.properties   |   1 -
 .../ftpdelete/messages/messages_fr_FR.properties   |   1 -
 .../ftpdelete/messages/messages_it_IT.properties   |   1 -
 .../ftpdelete/messages/messages_ja_JP.properties   |   1 -
 .../ftpdelete/messages/messages_ko_KR.properties   |   1 -
 .../ftpdelete/messages/messages_pt_BR.properties   |   1 -
 .../ftpdelete/messages/messages_zh_CN.properties   |   2 +-
 .../actions/ftp/ActionFtpExecutionTest.java        | 167 ++++++++++++++++++-
 .../ftpdelete/ActionFtpDeleteExecutionTest.java    | 180 ++++++++++++++++++++-
 21 files changed, 382 insertions(+), 42 deletions(-)

diff --git a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftp.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftp.adoc
index 7833c952d0..ff1c294643 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftp.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftp.adoc
@@ -92,7 +92,7 @@ For example: .txt$ : get all text files A.ENG:0-9.txt : files 
starting with A, e
 
 * All works fine (default)
 * At least we got x files
-* Nr errors less than
+* Nr errors at most
 
 |Limit files|Sets number of files associated with a condition of success.
 |===
@@ -119,8 +119,8 @@ What this action passes on to the next action. See 
xref:workflow/action-results.
 
 * All works fine (default): no file failed. No file matching the wildcard is 
also true.
 * At least we got x files: at least *Limit files* files were downloaded, 
whatever the number of errors.
-* Nr errors less than: the number of errors is at most *Limit files*. The 
download stops as soon as the number of errors reaches *Limit files*, and the 
action is still true then. Some failures before the download also count as 1 
error: see False.
-|False|The success condition is not met. Without *Nr errors less than*, the 
download stops at the first file that fails. The action is also false, before 
any download, when the server can't be reached or refuses the login, the remote 
directory doesn't exist, the wildcard is not a valid regular expression, or 
*Move files after retrieval* is checked while the move-to folder is empty, or 
doesn't exist and *Create folder* is unchecked. With *Nr errors less than*, an 
unreachable server, a ref [...]
+* Nr errors at most: after the action is ready to download files, the number 
of errors is at most *Limit files*. The download stops as soon as the number of 
errors reaches *Limit files*, and the action is still true then.
+|False|The success condition is not met. With *All works fine*, the download 
stops at the first file that fails. With *At least we got x files*, the 
download walks the whole list and checks the downloaded count at the end. The 
action is also false, whatever the success condition, when it fails before any 
download: the server can't be reached or refuses the login, the remote 
directory doesn't exist, the wildcard is not a valid regular expression, or 
*Move files after retrieval* is checked [...]
 |Errors|The number of files that failed, or 1 when the action fails before the 
download.
 |Result files|The downloaded files are added when *Add filename to result* is 
checked (the default). The previous result files are kept.
 |Result rows|Passed on unchanged.
diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftpdelete.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftpdelete.adoc
index 6520ca0e2f..0e60a2448c 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftpdelete.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/ftpdelete.adoc
@@ -81,7 +81,7 @@ The default is Passive mode.
 
 * All works fine
 * At least we delete x files
-* Nr errors less than
+* Nr errors at most
 
 |Limit files|Sets a limit to the number of deleted files (default 10).
 |===
@@ -108,8 +108,8 @@ What this action passes on to the next action. See 
xref:workflow/action-results.
 
 * All works fine (default): no file failed. No file matching the wildcard is 
also true, and so is *Copy previous results to args* without previous result 
rows.
 * At least we delete x files: at least *Limit files* files were deleted.
-* Nr errors less than: the number of errors is at most *Limit files*. A 
failure before deleting counts as 1 error, so the cases listed under False give 
true with 1 error when *Limit files* is 1 or more.
-|False|The success condition is not met, for example because the server can't 
be reached or refuses the login, the remote directory doesn't exist, the 
wildcard is not a valid regular expression, or *Wildcard* is empty while *Copy 
previous results to args* is unchecked. The number of errors is the number of 
files that failed, or 1 when the action fails before deleting. With *Nr errors 
less than*, these failures count as 1 error, so the action is true when *Limit 
files* is 1 or more.
+* Nr errors at most: after the action is ready to delete files, the number of 
errors is at most *Limit files*. The delete stops as soon as the number of 
errors reaches *Limit files*, and the action is still true then.
+|False|The success condition is not met. With *All works fine*, the delete 
stops at the first file that fails. With *At least we delete x files*, the 
delete runs to the end of the list and checks the deleted count at the end. The 
action is also false, whatever the success condition, when it fails before 
deleting: the server can't be reached or refuses the login, the remote 
directory doesn't exist, the wildcard is not a valid regular expression, or 
*Wildcard* is empty while *Copy previous [...]
 |Result files|Passed on unchanged.
 |Result rows|Passed on unchanged.
 |Files retrieved|The number of files deleted. When the remote directory has no 
files, or *Copy previous results to args* is checked without previous result 
rows, the value of the previous action is passed on unchanged.
diff --git 
a/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftp/ActionFtp.java
 
b/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftp/ActionFtp.java
index a76c6b553f..666fbffc5e 100644
--- 
a/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftp/ActionFtp.java
+++ 
b/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftp/ActionFtp.java
@@ -303,17 +303,20 @@ public class ActionFtp extends ActionBase implements 
Cloneable, IAction, IFtpCon
         downloadFiles(ftpClient, realMoveToFolder, download, result);
       }
     } catch (Exception e) {
+      // Stopping at the error limit already logged UnexpectedError per file; 
do not log again as a
+      // failure when Nr errors at most can still leave the action true.
       if (!download.successConditionBroken) {
         download.updateErrors();
+        logError(BaseMessages.getString(PKG, "ActionFTP.ErrorGetting", 
e.getMessage()), e);
       }
-      logError(BaseMessages.getString(PKG, "ActionFTP.ErrorGetting", 
e.getMessage()), e);
     } finally {
       FtpHelper.disconnect(getLogChannel(), ftpClient);
     }
 
     result.setNrErrors(download.nrErrors);
     result.setNrFilesRetrieved(download.nrFilesRetrieved);
-    result.setResult(!exitAction && download.isSuccess());
+    // Success conditions apply only once listing/matching is ready; setup 
failures stay false.
+    result.setResult(!exitAction && download.transferAttempted && 
download.isSuccess());
     download.log();
     return result;
   }
@@ -376,14 +379,17 @@ public class ActionFtp extends ActionBase implements 
Cloneable, IAction, IFtpCon
 
     Pattern pattern = Utils.isEmpty(wildcard) ? null : 
Pattern.compile(resolve(wildcard));
 
+    // Connection, listing and wildcard are ready: from here on, success 
conditions apply.
+    download.transferAttempted = true;
+
     for (FTPFile ftpFile : ftpFiles) {
       if (parentWorkflow.isStopped()) {
         throw new HopException(BaseMessages.getString(PKG, 
"ActionFTP.WorkflowStopped"));
       }
       if (download.successConditionBroken) {
-        throw new HopException(
-            BaseMessages.getString(
-                PKG, "ActionFTP.SuccesConditionBroken", 
String.valueOf(download.nrErrors)));
+        // Limit reached: stop quietly. Per-file UnexpectedError was already 
logged; do not throw
+        // into the outer catch (that would log a failure on an action that 
can still be true).
+        return;
       }
 
       String filename = ftpFile.getName();
@@ -662,6 +668,10 @@ public class ActionFtp extends ActionBase implements 
Cloneable, IAction, IFtpCon
     private long nrErrors = 0;
     private long nrFilesRetrieved = 0;
     private boolean successConditionBroken = false;
+
+    /** True once listing and wildcard matching are ready; false for setup 
failures. */
+    private boolean transferAttempted = false;
+
     private final int limitFiles = Const.toInt(resolve(getNrLimit()), 10);
 
     void updateErrors() {
@@ -673,6 +683,7 @@ public class ActionFtp extends ActionBase implements 
Cloneable, IAction, IFtpCon
     }
 
     boolean isSuccess() {
+      // SUCCESS_IF_ERRORS_LESS means "at most Limit files errors" (nrErrors 
<= limit).
       return (nrErrors == 0 && 
SUCCESS_IF_NO_ERRORS.equals(getSuccessCondition()))
           || (nrFilesRetrieved >= limitFiles
               && 
SUCCESS_IF_AT_LEAST_X_FILES_DOWNLOADED.equals(getSuccessCondition()))
diff --git 
a/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDelete.java
 
b/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDelete.java
index 9bf4846e4a..a720bd711c 100644
--- 
a/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDelete.java
+++ 
b/plugins/tech/ftp/src/main/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDelete.java
@@ -301,10 +301,15 @@ public class ActionFtpDelete extends ActionBase 
implements Cloneable, IAction, I
         return result;
       }
 
+      // Connection, listing and wildcard are ready: from here on, success 
conditions apply.
+      deletion.transferAttempted = true;
       deleteFiles(filenames, selector, ftpClient, sftpClient, deletion);
     } catch (Exception e) {
-      deletion.updateErrors();
-      logError(BaseMessages.getString(PKG, "ActionFTPDelete.ErrorGetting", 
e.getMessage()), e);
+      // deleteFiles already counted the file error that broke the condition; 
do not count again.
+      if (!deletion.successConditionBroken) {
+        deletion.updateErrors();
+        logError(BaseMessages.getString(PKG, "ActionFTPDelete.ErrorGetting", 
e.getMessage()), e);
+      }
     } finally {
       FtpHelper.disconnect(getLogChannel(), ftpClient);
       if (sftpClient != null) {
@@ -316,7 +321,8 @@ public class ActionFtpDelete extends ActionBase implements 
Cloneable, IAction, I
       }
     }
 
-    result.setResult(deletion.isSuccess());
+    // Success conditions apply only once listing/matching is ready; setup 
failures stay false.
+    result.setResult(deletion.transferAttempted && deletion.isSuccess());
     result.setNrFilesRetrieved(deletion.nrFilesDeleted);
     result.setNrErrors(deletion.nrErrors);
     return result;
@@ -361,8 +367,9 @@ public class ActionFtpDelete extends ActionBase implements 
Cloneable, IAction, I
         return;
       }
       if (deletion.successConditionBroken) {
-        throw new HopException(
-            BaseMessages.getString(PKG, 
"ActionFTPDelete.SuccesConditionBroken"));
+        // Limit reached: stop quietly. Per-file UnexpectedError was already 
logged; do not throw
+        // into the outer catch (that would log a failure on an action that 
can still be true).
+        return;
       }
       if (isDebug()) {
         logDebug(BaseMessages.getString(PKG, "ActionFTPDelete.AnalysingFile", 
filename));
@@ -385,8 +392,7 @@ public class ActionFtpDelete extends ActionBase implements 
Cloneable, IAction, I
         deletion.updateErrors();
         logError(BaseMessages.getString(PKG, "ActionFtp.UnexpectedError", 
e.getMessage()));
         if (deletion.successConditionBroken) {
-          throw new HopException(
-              BaseMessages.getString(PKG, 
"ActionFTPDelete.SuccesConditionBroken"));
+          return;
         }
       }
     }
@@ -548,6 +554,10 @@ public class ActionFtpDelete extends ActionBase implements 
Cloneable, IAction, I
     private long nrErrors = 0;
     private long nrFilesDeleted = 0;
     private boolean successConditionBroken = false;
+
+    /** True once listing and wildcard matching are ready; false for setup 
failures. */
+    private boolean transferAttempted = false;
+
     private final int limitFiles = Const.toInt(resolve(getNrLimitSuccess()), 
10);
 
     void updateErrors() {
@@ -561,6 +571,7 @@ public class ActionFtpDelete extends ActionBase implements 
Cloneable, IAction, I
     }
 
     boolean isSuccess() {
+      // SUCCESS_IF_ERRORS_LESS means "at most Limit files errors" (nrErrors 
<= limit).
       return (nrErrors == 0 && 
SUCCESS_IF_ALL_FILES_DOWNLOADED.equals(getSuccessCondition()))
           || (nrFilesDeleted >= limitFiles
               && 
SUCCESS_IF_AT_LEAST_X_FILES_DOWNLOADED.equals(getSuccessCondition()))
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_en_US.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_en_US.properties
index b7b6e549f5..a3b9d32cc5 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_en_US.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_en_US.properties
@@ -123,7 +123,7 @@ ActionFtp.SuccessCondition.Label=Success on
 ActionFtp.SuccessOn.Group.Label=Success condition
 ActionFtp.SuccessWhenAllWorksFine.Label=All works fine
 ActionFtp.SuccessWhenAtLeat.Label=At least we got x files
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=Nr errors less than
+ActionFtp.SuccessWhenNrErrorsLessThan.Label=Nr errors at most
 ActionFtp.Tab.Advanced.Label=Advanced
 ActionFtp.Tab.Files.Label=Files
 ActionFtp.Tab.General.Label=General
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_es_AR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_es_AR.properties
index 537ab6810f..4a257e1d41 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_es_AR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_es_AR.properties
@@ -118,7 +118,6 @@ ActionFtp.SuccessCondition.Label=\u00C9xito si
 ActionFtp.SuccessOn.Group.Label=Condici\u00F3n de \u00E9xito
 ActionFtp.SuccessWhenAllWorksFine.Label=Todo funciona bien
 ActionFtp.SuccessWhenAtLeat.Label=Se obtuvieron al menos x archivos
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=El nro. de errores es menor a
 ActionFtp.Tab.Advanced.Label=Avanzado
 ActionFtp.Tab.Files.Label=Archivos
 ActionFtp.Tab.General.Label=General
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_fr_FR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_fr_FR.properties
index 4cf12a8ac5..0e77fb647b 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_fr_FR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_fr_FR.properties
@@ -120,7 +120,6 @@ ActionFtp.SuccessCondition.Label=Condition de succ\u00E8s
 ActionFtp.SuccessOn.Group.Label=Condition de succ\u00E8s
 ActionFtp.SuccessWhenAllWorksFine.Label=Aucune erreur n''est report\u00E9e
 ActionFtp.SuccessWhenAtLeat.Label=x fichiers au moins ont \u00E9t\u00E9 
r\u00E9cup\u00E9r\u00E9s 
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=Nombre erreurs inf\u00E9rieur 
\u00E0
 ActionFtp.Tab.Advanced.Label=Avanc\u00E9
 ActionFtp.Tab.Files.Label=Fichiers
 ActionFtp.Tab.General.Label=G\u00E9n\u00E9ral
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_it_IT.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_it_IT.properties
index 2f9e989def..68c556d1c7 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_it_IT.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_it_IT.properties
@@ -118,7 +118,6 @@ ActionFtp.SuccessCondition.Label=Successo
 ActionFtp.SuccessOn.Group.Label=Condizione di successo
 ActionFtp.SuccessWhenAllWorksFine.Label=Tutto funziona correttamente
 ActionFtp.SuccessWhenAtLeat.Label=Almeno x file
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=N. errori inferiore a
 ActionFtp.Tab.Advanced.Label=Avanzate
 ActionFtp.Tab.Files.Label=File
 ActionFtp.Tab.General.Label=Generale
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_ko_KR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_ko_KR.properties
index bf5e0e3c39..c65cd45c64 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_ko_KR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_ko_KR.properties
@@ -117,7 +117,6 @@ ActionFtp.SuccessCondition.Label=\uC131\uACF5 \uC870\uAC74
 ActionFtp.SuccessOn.Group.Label=\uC131\uACF5 \uC870\uAC74
 ActionFtp.SuccessWhenAllWorksFine.Label=\uBAA8\uB4E0 \uC791\uC5C5 \uC644\uB8CC
 ActionFtp.SuccessWhenAtLeat.Label=\uCD5C\uC18C\uD55C \uBA87\uAC1C\uC758 
\uD30C\uC77C \uBC1B\uC74C
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=\uC624\uB958 \uAC1C\uC218\uAC00 
...\uBCF4\uB2E4 \uC801\uB2E4
 ActionFtp.Tab.Advanced.Label=\uACE0\uAE09
 ActionFtp.Tab.Files.Label=\uD30C\uC77C
 ActionFtp.Tab.General.Label=\uC77C\uBC18
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_pt_BR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_pt_BR.properties
index ab4783e81e..812a3aaf9c 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_pt_BR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_pt_BR.properties
@@ -81,7 +81,6 @@ ActionFTP.SuccesConditionBroken=Condi\u00E7\u00E3o de sucesso 
n\u00E3o satisfeit
 ActionFtp.SuccessCondition.Label=Sucesso em
 ActionFtp.SuccessOn.Group.Label=Condi\u00E7\u00E3o de sucesso
 ActionFtp.SuccessWhenAllWorksFine.Label=Tudo funciona bem
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=quantidade de erros menor que
 ActionFtp.Tab.Advanced.Label=Avan\u00E7ado
 ActionFtp.Tab.Files.Label=Arquivos
 ActionFtp.Tab.General.Label=Geral
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_zh_CN.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_zh_CN.properties
index 1ff9a63d06..78d92857df 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_zh_CN.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftp/messages/messages_zh_CN.properties
@@ -120,7 +120,7 @@ ActionFtp.SuccessCondition.Label=\u6210\u529F\u6761\u4EF6
 ActionFtp.SuccessOn.Group.Label=\u6210\u529F\u6761\u4EF6
 ActionFtp.SuccessWhenAllWorksFine.Label=\u4E00\u5207\u5DE5\u4F5C\u6B63\u5E38
 
ActionFtp.SuccessWhenAtLeat.Label=\u83B7\u53D6\u6587\u4EF6\u6570\u4E0D\u5C0F\u4E8E
-ActionFtp.SuccessWhenNrErrorsLessThan.Label=\u9519\u8BEF\u6570\u5C0F\u4E8E
+ActionFtp.SuccessWhenNrErrorsLessThan.Label=\u9519\u8BEF\u6570\u4E0D\u8D85\u8FC7
 ActionFtp.Tab.Advanced.Label=\u9AD8\u7EA7
 ActionFtp.Tab.Files.Label=\u6587\u4EF6
 ActionFtp.Tab.General.Label=\u4E00\u822C
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_en_US.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_en_US.properties
index 7a70b37b8c..e4c4543801 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_en_US.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_en_US.properties
@@ -87,7 +87,7 @@ ActionFtpDelete.SuccessCondition.Label=Success on
 ActionFtpDelete.SuccessOn.Group.Label=Success condition
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=All works fine
 ActionFtpDelete.SuccessWhenAtLeat.Label=At least we delete x files
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=Nr errors less than
+ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=Nr errors at most
 ActionFtpDelete.Tab.Files.Label=Files
 ActionFtpDelete.Tab.General.Label=General
 ActionFtpDelete.Tab.Socks.Label=Socks Proxy
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_es_AR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_es_AR.properties
index 9e1b97eab2..7d662b1c7d 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_es_AR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_es_AR.properties
@@ -82,7 +82,6 @@ ActionFtpDelete.SuccessCondition.Label=Condici\u00F3n de 
\u00E9xito
 ActionFtpDelete.SuccessOn.Group.Label=Condici\u00F3n de \u00E9xito
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=Todo funciona correctamente
 ActionFtpDelete.SuccessWhenAtLeat.Label=Se eliminaron al menos x archivos
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=El n\u00FAmero de errores 
fue menor que x
 ActionFtpDelete.Tab.Files.Label=Archivos
 ActionFtpDelete.Tab.General.Label=General
 ActionFtpDelete.Tab.Socks.Label=Proxy Socks
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_fr_FR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_fr_FR.properties
index 6a54a85b34..1bcc908981 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_fr_FR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_fr_FR.properties
@@ -86,7 +86,6 @@ ActionFtpDelete.SuccessCondition.Label=Condition de 
succ\u00E8s
 ActionFtpDelete.SuccessOn.Group.Label=Condition de succ\u00E8s
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=Aucune erreur n''a \u00E9t\u00E9 
report\u00E9e
 ActionFtpDelete.SuccessWhenAtLeat.Label=Au moins x fichiers ont \u00E9t\u00E9 
supprim\u00E9s
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=Nombre d''erreur 
inf\u00E9rieur \u00E0
 ActionFtpDelete.Tab.Files.Label=Fichiers
 ActionFtpDelete.Tab.General.Label=G\u00E9n\u00E9ral
 ActionFtpDelete.Tab.Socks.Label=Proxy
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_it_IT.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_it_IT.properties
index 6ced2ab5be..af61f24a7d 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_it_IT.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_it_IT.properties
@@ -83,7 +83,6 @@ ActionFtpDelete.SuccessCondition.Label=Successo se
 ActionFtpDelete.SuccessOn.Group.Label=Condizione di successo
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=Tutto funziona correttamente
 ActionFtpDelete.SuccessWhenAtLeat.Label=Cancella almeno x files
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=N. errori inferiore a
 ActionFtpDelete.Tab.Files.Label=File
 ActionFtpDelete.Tab.General.Label=Generale
 ActionFtpDelete.Tab.Socks.Label=Proxy Socks
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ja_JP.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ja_JP.properties
index e1dab8d68f..f7359e464b 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ja_JP.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ja_JP.properties
@@ -86,7 +86,6 @@ ActionFtpDelete.SuccessCondition.Label=\u6761\u4EF6
 
ActionFtpDelete.SuccessOn.Group.Label=\u51E6\u7406\u6761\u4EF6\u306E\u8A2D\u5B9A
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=\u3059\u3079\u3066\u6B63\u5E38
 ActionFtpDelete.SuccessWhenAtLeat.Label=\u6700\u4F4E 
x\u30D5\u30A1\u30A4\u30EB\u3092\u524A\u9664
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=\u30A8\u30E9\u30FC\u304C\u6307\u5B9A\u3057\u305F\u6570\u3088\u308A\u5C11\u306A\u3044\u5834\u5408
 ActionFtpDelete.Tab.Files.Label=\u30D5\u30A1\u30A4\u30EB
 ActionFtpDelete.Tab.General.Label=\u5168\u822C
 ActionFtpDelete.Tab.Socks.Label=Socks \u30D7\u30ED\u30AD\u30B7
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ko_KR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ko_KR.properties
index cb59cad2bf..cb94764d44 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ko_KR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_ko_KR.properties
@@ -82,7 +82,6 @@ ActionFtpDelete.SuccessCondition.Label=\uC131\uACF5 
\uC870\uAC74
 ActionFtpDelete.SuccessOn.Group.Label=\uC131\uACF5 \uC870\uAC74
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=\uBAA8\uB4E0 \uC791\uC5C5 
\uC644\uB8CC
 ActionFtpDelete.SuccessWhenAtLeat.Label=\uCD5C\uC18C\uD55C \uBA87\uAC1C\uC758 
\uD30C\uC77C \uC0AD\uC81C
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=\uC624\uB958 
\uAC1C\uC218\uAC00 ...\uBCF4\uB2E4 \uC801\uB2E4
 ActionFtpDelete.Tab.Files.Label=\uD30C\uC77C
 ActionFtpDelete.Tab.General.Label=\uC77C\uBC18
 ActionFtpDelete.Tab.Socks.Label=Socks \uD504\uB85D\uC2DC
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_pt_BR.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_pt_BR.properties
index 0d8e69c908..4414d6cfd2 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_pt_BR.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_pt_BR.properties
@@ -65,7 +65,6 @@ ActionFtpDelete.SocksProxyUsername.Label=Nome de usu\u00E1rio:
 ActionFtpDelete.SuccessCondition.Label=Sucesso em
 ActionFtpDelete.SuccessOn.Group.Label=Condi\u00E7\u00E3o de sucesso
 ActionFtpDelete.SuccessWhenAllWorksFine.Label=Tudo funciona bem
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=quantidade de erros menor que
 ActionFtpDelete.Tab.Files.Label=Arquivos
 ActionFtpDelete.Tab.General.Label=Geral
 ActionFtpDelete.Tab.Socks.Label=Proxy para socks
diff --git 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_zh_CN.properties
 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_zh_CN.properties
index 08792010a0..de5f114880 100644
--- 
a/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_zh_CN.properties
+++ 
b/plugins/tech/ftp/src/main/resources/org/apache/hop/workflow/actions/ftpdelete/messages/messages_zh_CN.properties
@@ -87,7 +87,7 @@ 
ActionFtpDelete.SuccessCondition.Label=\u6210\u529F\u6761\u4EF6
 ActionFtpDelete.SuccessOn.Group.Label=\u6210\u529F\u6761\u4EF6
 
ActionFtpDelete.SuccessWhenAllWorksFine.Label=\u4E00\u5207\u5DE5\u4F5C\u6B63\u5E38
 
ActionFtpDelete.SuccessWhenAtLeat.Label=\u5220\u9664\u7684\u6587\u4EF6\u6570\u4E0D\u5C11\u4E8E
-ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=\u9519\u8BEF\u6570\u5C11\u4E8E
+ActionFtpDelete.SuccessWhenNrErrorsLessThan.Label=\u9519\u8BEF\u6570\u4E0D\u8D85\u8FC7
 ActionFtpDelete.Tab.Files.Label=\u6587\u4EF6
 ActionFtpDelete.Tab.General.Label=\u4E00\u822C
 ActionFtpDelete.Tab.Socks.Label=socks\u4EE3\u7406
diff --git 
a/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftp/ActionFtpExecutionTest.java
 
b/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftp/ActionFtpExecutionTest.java
index 68b1baa7fb..b34769355d 100644
--- 
a/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftp/ActionFtpExecutionTest.java
+++ 
b/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftp/ActionFtpExecutionTest.java
@@ -31,7 +31,9 @@ import java.util.Comparator;
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.hop.core.HopEnvironment;
 import org.apache.hop.core.Result;
+import org.apache.hop.core.logging.HopLogStore;
 import org.apache.hop.core.logging.LogLevel;
+import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.metadata.api.IHopMetadataProvider;
 import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
 import org.apache.hop.vfs.ftp.FtpHelper;
@@ -249,7 +251,7 @@ class ActionFtpExecutionTest {
 
   @Test
   @DisplayName("Moving without saying where to is refused before anything is 
connected")
-  void movingWithoutATargetFolderIsRefused(@TempDir Path targetDir) throws 
Exception {
+  void movingWithoutATargetFolderIsRefused(@TempDir Path targetDir) {
     ActionFtp action = configure(targetDir);
     action.setMoveFiles(true);
     action.setMoveToDirectory("");
@@ -317,8 +319,8 @@ class ActionFtpExecutionTest {
   }
 
   @Test
-  @DisplayName("\"Fewer errors than\" tolerates a failure the default 
condition would not")
-  void successWhenFewerErrorsThan(@TempDir Path targetDir) throws Exception {
+  @DisplayName("\"At most N errors\" tolerates a failure the default condition 
would not")
+  void successWhenErrorsAtMost(@TempDir Path targetDir) throws Exception {
     server.writeFile("existing.txt", "the-server-copy");
     Files.writeString(targetDir.resolve("existing.txt"), "the-local-copy");
 
@@ -330,10 +332,148 @@ class ActionFtpExecutionTest {
 
     Result result = action.execute(new Result(), 0);
 
-    assertTrue(result.isResult(), "one error is fewer than the five allowed");
+    assertTrue(result.isResult(), "one error is within the five allowed");
     assertEquals(1, result.getNrErrors());
   }
 
+  @Test
+  @DisplayName("\"At most N errors\" is still true when the error count equals 
the limit")
+  void successWhenErrorsEqualTheLimit(@TempDir Path targetDir) throws 
Exception {
+    server.writeFile("existing.txt", "the-server-copy");
+    Files.writeString(targetDir.resolve("existing.txt"), "the-local-copy");
+
+    ActionFtp action = configure(targetDir);
+    action.setOnlyGettingNewFiles(true);
+    action.setIfFileExistsOperation(ActionFtp.IfFileExistsOperation.FAIL);
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("1");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertTrue(result.isResult(), "exactly Limit files errors still counts as 
success");
+    assertEquals(1, result.getNrErrors());
+  }
+
+  @Test
+  @DisplayName(
+      "\"At most N errors\" stops once the limit is reached and does not log 
that stop as a failure")
+  void errorsAtMostStopsWithoutLoggingTheStopAsAFailure(@TempDir Path 
targetDir) throws Exception {
+    // A second existing file forces another loop iteration after the limit is 
hit; that used to
+    // throw into the outer catch and log ErrorGetting on an action that still 
follows success.
+    server.writeFile("one.txt", "server-one");
+    server.writeFile("two.txt", "server-two");
+    Files.writeString(targetDir.resolve("one.txt"), "local-one");
+    Files.writeString(targetDir.resolve("two.txt"), "local-two");
+
+    ActionFtp action = configure(targetDir);
+    action.setOnlyGettingNewFiles(true);
+    action.setIfFileExistsOperation(ActionFtp.IfFileExistsOperation.FAIL);
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("1");
+    action.setLogLevel(LogLevel.ERROR);
+
+    String logChannelId = action.getLogChannel().getLogChannelId();
+    int logFrom = HopLogStore.getLastBufferLineNr();
+    Result result = action.execute(new Result(), 0);
+    String log = HopLogStore.getAppender().getBuffer(logChannelId, true, 
logFrom).toString();
+
+    assertTrue(result.isResult(), "exactly Limit files errors still counts as 
success");
+    assertEquals(1, result.getNrErrors());
+    assertTrue(
+        log.contains(localFileExistsLogFragment()),
+        "the existing-file failure must still be logged:\n" + log);
+    assertFalse(
+        log.contains(errorGettingLogFragment()),
+        "stopping at the limit must not look like an action failure:\n" + log);
+    assertFalse(
+        log.contains(
+            BaseMessages.getString(ActionFtp.class, 
"ActionFTP.SuccesConditionBroken", "1")),
+        "stopping at the limit must not look like an action failure:\n" + log);
+  }
+
+  @Test
+  @DisplayName("\"At least X files\" keeps going after a file that already 
exists locally")
+  void atLeastXFilesContinuesAfterAnError(@TempDir Path targetDir) throws 
Exception {
+    server.writeFile("existing.txt", "the-server-copy");
+    server.writeFile("fresh.txt", "download me");
+    Files.writeString(targetDir.resolve("existing.txt"), "the-local-copy");
+
+    ActionFtp action = configure(targetDir);
+    action.setOnlyGettingNewFiles(true);
+    action.setIfFileExistsOperation(ActionFtp.IfFileExistsOperation.FAIL);
+    
action.setSuccessCondition(ActionFtp.SUCCESS_IF_AT_LEAST_X_FILES_DOWNLOADED);
+    action.setNrLimit("1");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertTrue(result.isResult(), "one downloaded file meets the limit");
+    assertEquals(1, result.getNrFilesRetrieved());
+    assertEquals(1, result.getNrErrors());
+    assertEquals("download me", 
Files.readString(targetDir.resolve("fresh.txt")));
+    assertEquals("the-local-copy", 
Files.readString(targetDir.resolve("existing.txt")));
+  }
+
+  @Test
+  @DisplayName("An unreachable server fails whatever the success condition")
+  void unreachableServerFailsEvenWithErrorsAtMost(@TempDir Path targetDir) {
+    ActionFtp action = configure(targetDir);
+    action.setServerPort("1");
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult(), "a failure before any download must not 
follow the success hop");
+    assertTrue(result.getNrErrors() > 0);
+  }
+
+  @Test
+  @DisplayName("A refused login fails whatever the success condition")
+  void refusedLoginFailsEvenWithErrorsAtMost(@TempDir Path targetDir) throws 
Exception {
+    server.writeFile("stays.txt", "stays");
+
+    ActionFtp action = configure(targetDir);
+    action.setPassword("wrong-password");
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertFalse(Files.exists(targetDir.resolve("stays.txt")));
+  }
+
+  @Test
+  @DisplayName("An invalid wildcard fails whatever the success condition")
+  void invalidWildcardFailsEvenWithErrorsAtMost(@TempDir Path targetDir) 
throws Exception {
+    server.writeFile("wanted.txt", "payload");
+
+    ActionFtp action = configure(targetDir);
+    action.setWildcard("[invalid");
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertFalse(Files.exists(targetDir.resolve("wanted.txt")));
+  }
+
+  @Test
+  @DisplayName("A missing remote directory fails whatever the success 
condition")
+  void missingRemoteDirectoryFailsEvenWithErrorsAtMost(@TempDir Path 
targetDir) {
+    ActionFtp action = configure(targetDir);
+    action.setRemoteDirectory("/not-there");
+    action.setSuccessCondition(ActionFtp.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimit("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+  }
+
   @Test
   @DisplayName("A named FTP connection replaces the server settings on the 
action")
   void aNamedConnectionIsUsed(@TempDir Path targetDir) throws Exception {
@@ -366,7 +506,7 @@ class ActionFtpExecutionTest {
 
   @Test
   @DisplayName("A connection name which isn't in the metadata is an error")
-  void anUnknownConnectionIsAnError(@TempDir Path targetDir) throws Exception {
+  void anUnknownConnectionIsAnError(@TempDir Path targetDir) {
     ActionFtp action = configure(targetDir);
     action.setMetadataProvider(new MemoryMetadataProvider());
     action.setConnection("nowhere");
@@ -505,6 +645,23 @@ class ActionFtpExecutionTest {
     return workflowEngine;
   }
 
+  /** Fixed text of {@code ActionFTP.LocalFileExists} before the {@code {0}} 
placeholder. */
+  private static String localFileExistsLogFragment() {
+    return messagePrefix(ActionFtp.class, "ActionFTP.LocalFileExists");
+  }
+
+  /** Fixed text of {@code ActionFTP.ErrorGetting} before the {@code {0}} 
placeholder. */
+  private static String errorGettingLogFragment() {
+    return messagePrefix(ActionFtp.class, "ActionFTP.ErrorGetting");
+  }
+
+  private static String messagePrefix(Class<?> pkg, String key) {
+    final String marker = "<<<>>>";
+    String formatted = BaseMessages.getString(pkg, key, marker);
+    int placeholder = formatted.indexOf(marker);
+    return placeholder >= 0 ? formatted.substring(0, placeholder) : formatted;
+  }
+
   private ActionFtp configure(Path targetDir) {
     ActionFtp action = new ActionFtp("FTP get");
     action.setServerName(FtpTestServer.HOST);
diff --git 
a/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDeleteExecutionTest.java
 
b/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDeleteExecutionTest.java
index dbff13dc1e..5bd6af0e6f 100644
--- 
a/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDeleteExecutionTest.java
+++ 
b/plugins/tech/ftp/src/test/java/org/apache/hop/workflow/actions/ftpdelete/ActionFtpDeleteExecutionTest.java
@@ -32,9 +32,11 @@ import java.util.List;
 import org.apache.hop.core.HopEnvironment;
 import org.apache.hop.core.Result;
 import org.apache.hop.core.RowMetaAndData;
+import org.apache.hop.core.logging.HopLogStore;
 import org.apache.hop.core.logging.LogLevel;
 import org.apache.hop.core.row.RowMeta;
 import org.apache.hop.core.row.value.ValueMetaString;
+import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.vfs.ftp.FtpSecurityMode;
 import org.apache.hop.vfs.ftp.FtpTestServer;
 import org.apache.hop.workflow.WorkflowMeta;
@@ -118,7 +120,7 @@ class ActionFtpDeleteExecutionTest {
 
   @Test
   @DisplayName("An empty directory is a success, not a failure")
-  void anEmptyDirectoryIsFine() throws Exception {
+  void anEmptyDirectoryIsFine() {
     ActionFtpDelete action = configure();
     action.setWildcard(".*");
 
@@ -182,8 +184,8 @@ class ActionFtpDeleteExecutionTest {
   }
 
   @Test
-  @DisplayName("\"Fewer errors than\" tolerates a refused delete the default 
condition would not")
-  void successWhenFewerErrorsThan() throws Exception {
+  @DisplayName("\"At most N errors\" tolerates a refused delete the default 
condition would not")
+  void successWhenErrorsAtMost() throws Exception {
     Files.createDirectories(serverRoot.resolve("a-folder"));
 
     ActionFtpDelete action = configure();
@@ -193,7 +195,160 @@ class ActionFtpDeleteExecutionTest {
 
     Result result = action.execute(new Result(), 0);
 
-    assertTrue(result.isResult(), "one error is fewer than the five allowed");
+    assertTrue(result.isResult(), "one error is within the five allowed");
+  }
+
+  @Test
+  @DisplayName("\"At most N errors\" is still true when the error count equals 
the limit")
+  void successWhenErrorsEqualTheLimit() throws Exception {
+    Files.createDirectories(serverRoot.resolve("a-folder"));
+
+    ActionFtpDelete action = configure();
+    action.setWildcard(".*");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("1");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertTrue(result.isResult(), "exactly Limit files errors still counts as 
success");
+    assertEquals(1, result.getNrErrors());
+  }
+
+  @Test
+  @DisplayName("\"At most N errors\" at the limit does not log the stop as an 
action failure")
+  void errorsAtMostDoesNotLogTheStopAsAFailure() throws Exception {
+    // A refused delete of a directory: deleteFiles used to throw into the 
outer catch and log
+    // ErrorGetting even when Nr errors at most still leaves the action true.
+    Files.createDirectories(serverRoot.resolve("a-folder"));
+
+    ActionFtpDelete action = configure();
+    action.setWildcard(".*");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("1");
+    action.setLogLevel(LogLevel.ERROR);
+
+    String logChannelId = action.getLogChannel().getLogChannelId();
+    int logFrom = HopLogStore.getLastBufferLineNr();
+    Result result = action.execute(new Result(), 0);
+    String log = HopLogStore.getAppender().getBuffer(logChannelId, true, 
logFrom).toString();
+
+    assertTrue(result.isResult(), "exactly Limit files errors still counts as 
success");
+    assertEquals(1, result.getNrErrors());
+    assertTrue(
+        log.contains(unexpectedErrorLogFragment()),
+        "the refused delete must still be logged:\n" + log);
+    assertFalse(
+        log.contains(errorGettingLogFragment()),
+        "stopping at the limit must not look like an action failure:\n" + log);
+    assertFalse(
+        log.contains(
+            BaseMessages.getString(ActionFtpDelete.class, 
"ActionFTPDelete.SuccesConditionBroken")),
+        "stopping at the limit must not look like an action failure:\n" + log);
+  }
+
+  @Test
+  @DisplayName("\"At least X files\" keeps going after a refused delete")
+  void atLeastXFilesContinuesAfterAnError() throws Exception {
+    Files.createDirectories(serverRoot.resolve("a-folder"));
+    server.writeFile("keep-going.txt", "delete me");
+
+    ActionFtpDelete action = configure();
+    action.setWildcard(".*");
+    
action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_AT_LEAST_X_FILES_DOWNLOADED);
+    action.setNrLimitSuccess("1");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertTrue(result.isResult(), "one successful delete meets the limit");
+    assertEquals(1, result.getNrFilesRetrieved());
+    assertEquals(1, result.getNrErrors());
+    assertNull(server.readFile("keep-going.txt"));
+    assertTrue(Files.exists(serverRoot.resolve("a-folder")));
+  }
+
+  @Test
+  @DisplayName("An unreachable server fails whatever the success condition")
+  void unreachableServerFailsEvenWithErrorsAtMost() {
+    ActionFtpDelete action = configure();
+    action.setWildcard(".*");
+    action.setServerPort("1");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult(), "a failure before any delete must not 
follow the success hop");
+    assertTrue(result.getNrErrors() > 0);
+  }
+
+  @Test
+  @DisplayName("A refused login fails whatever the success condition")
+  void refusedLoginFailsEvenWithErrorsAtMost() throws Exception {
+    server.writeFile("report.txt", "stays");
+
+    ActionFtpDelete action = configure();
+    action.setWildcard(".*");
+    action.setPassword("wrong-password");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertNotNull(server.readFile("report.txt"));
+  }
+
+  @Test
+  @DisplayName("An invalid wildcard fails whatever the success condition")
+  void invalidWildcardFailsEvenWithErrorsAtMost() throws Exception {
+    server.writeFile("report.txt", "stays");
+
+    ActionFtpDelete action = configure();
+    action.setWildcard("[invalid");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertNotNull(server.readFile("report.txt"));
+  }
+
+  @Test
+  @DisplayName("A missing remote directory fails whatever the success 
condition")
+  void missingRemoteDirectoryFailsEvenWithErrorsAtMost() throws Exception {
+    server.writeFile("stays.txt", "stays");
+
+    ActionFtpDelete action = configure();
+    action.setRemoteDirectory("/not-there");
+    action.setWildcard(".*");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertNotNull(server.readFile("stays.txt"));
+  }
+
+  @Test
+  @DisplayName("An empty wildcard fails whatever the success condition")
+  void emptyWildcardFailsEvenWithErrorsAtMost() throws Exception {
+    server.writeFile("report.txt", "stays");
+
+    ActionFtpDelete action = configure();
+    action.setWildcard("");
+    action.setSuccessCondition(ActionFtpDelete.SUCCESS_IF_ERRORS_LESS);
+    action.setNrLimitSuccess("10");
+
+    Result result = action.execute(new Result(), 0);
+
+    assertFalse(result.isResult());
+    assertTrue(result.getNrErrors() > 0);
+    assertNotNull(server.readFile("report.txt"));
   }
 
   @Test
@@ -280,6 +435,23 @@ class ActionFtpDeleteExecutionTest {
     return workflowEngine;
   }
 
+  /** Fixed text of {@code ActionFtp.UnexpectedError} before the {@code {0}} 
placeholder. */
+  private static String unexpectedErrorLogFragment() {
+    return messagePrefix(ActionFtpDelete.class, "ActionFtp.UnexpectedError");
+  }
+
+  /** Fixed text of {@code ActionFTPDelete.ErrorGetting} before the {@code 
{0}} placeholder. */
+  private static String errorGettingLogFragment() {
+    return messagePrefix(ActionFtpDelete.class, 
"ActionFTPDelete.ErrorGetting");
+  }
+
+  private static String messagePrefix(Class<?> pkg, String key) {
+    final String marker = "<<<>>>";
+    String formatted = BaseMessages.getString(pkg, key, marker);
+    int placeholder = formatted.indexOf(marker);
+    return placeholder >= 0 ? formatted.substring(0, placeholder) : formatted;
+  }
+
   private ActionFtpDelete configure() {
     ActionFtpDelete action = new ActionFtpDelete("FTP delete");
     action.setProtocol(ActionFtpDelete.PROTOCOL_FTP);

Reply via email to