From 7efabbfdfea87079c72b3dfcde2334da05482fc9 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Thu, 6 Jun 2024 14:23:43 -0400 Subject: [PATCH] better handle destfn rename failures by setting and catching new_name=None --- sarracenia/flow/__init__.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/sarracenia/flow/__init__.py b/sarracenia/flow/__init__.py index 55b24d886..f24f75fe3 100644 --- a/sarracenia/flow/__init__.py +++ b/sarracenia/flow/__init__.py @@ -734,7 +734,7 @@ def sundew_getDestInfos(self, msg, currentFileOption, filename): if destFileName == None or type(destFileName) != str: logger.error( f"DESTFNSCRIPT {dfm} return value must be the new file name as a string. This one returned {destFileName}, ignoring") - destFileName=filename + return None elif spec == 'TIME': timeSuffix = ':' + time.strftime("%Y%m%d%H%M%S", time.gmtime()) @@ -749,9 +749,8 @@ def sundew_getDestInfos(self, msg, currentFileOption, filename): timeSuffix = ':' + parts[-1] else: - logger.error("Don't understand this DESTFN parameter: %s" % - spec) - return filename + logger.error( f"invalid DESTFN parameter: {spec}" ) + return None return destFileName + satnet + timeSuffix @@ -1630,6 +1629,14 @@ def do_download(self) -> None: self.worklist.ok.append(msg) continue + if not 'new_dir' in msg or not msg['new_dir']: + self.reject(msg, 422, f"new_dir message field missing, do not know which directory to put file in. skipping." ) + continue + + if not 'new_file' in msg or not msg['new_file']: + self.reject(msg, 422, f"new_file message field missing, do not know name of file to write. skipping." ) + continue + new_path = msg['new_dir'] + os.path.sep + msg['new_file'] new_file = msg['new_file'] @@ -2717,6 +2724,14 @@ def do_send(self): for msg in self.worklist.incoming: + if not 'new_dir' in msg or not msg['new_dir']: + self.reject(msg, 422, f"new_dir message field missing, do not know which directory to put file in. skipping." ) + continue + + if not 'new_file' in msg or not msg['new_file']: + self.reject(msg, 422, f"new_file message field missing, do not know name of file to write. skipping." ) + continue + # weed out non-file transfer operations that are configured to not be done. if 'fileOp' in msg: if ('directory' in msg['fileOp']) and ('remove' in msg['fileOp']) and ( 'rmdir' not in self.o.fileEvents ):