Skip to content

Commit

Permalink
better handle destfn rename failures by setting and catching new_name…
Browse files Browse the repository at this point in the history
…=None
  • Loading branch information
petersilva committed Jun 6, 2024
1 parent 019253e commit 7efabbf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions sarracenia/flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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


Expand Down Expand Up @@ -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']

Expand Down Expand Up @@ -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 ):
Expand Down

0 comments on commit 7efabbf

Please sign in to comment.