Skip to content

Commit

Permalink
fix for crash from #699 when contentType missing on sent files.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersilva committed Jun 20, 2023
1 parent 46e6d4e commit 927c0f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sarracenia/flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,8 +1951,8 @@ def send(self, msg, options):
local_path = '/' + msg['relPath']

# older versions don't include the contentType, so patch it here.
if 'contentType' not in msg:
m['contentType'] = magic.from_file(new_file,mime=True)
if 'contentType' not in msg and not 'fileOp' in msg:
msg['contentType'] = magic.from_file(local_path,mime=True)

local_dir = os.path.dirname(local_path).replace('\\', '/')
local_file = os.path.basename(local_path).replace('\\', '/')
Expand Down Expand Up @@ -2074,6 +2074,8 @@ def send(self, msg, options):
return False

if 'directory' in msg['fileOp'] :
if 'contentType' not in msg:
msg['contentType'] = 'text/directory'
if hasattr(self.proto[self.scheme], 'delete'):
logger.debug( f"message is to mkdir {new_file}")
if not self.o.dry_run:
Expand All @@ -2089,6 +2091,8 @@ def send(self, msg, options):
#=================================

if 'hlink' in msg['fileOp']:
if 'contentType' not in msg:
msg['contentType'] = 'text/link'
if hasattr(self.proto[self.scheme], 'link'):
logger.debug("message is to link %s to: %s" % (new_file, msg['fileOp']['hlink']))
if not self.o.dry_run:
Expand All @@ -2097,6 +2101,8 @@ def send(self, msg, options):
logger.error("%s, hardlinks not supported" % self.scheme)
return False
elif 'link' in msg['fileOp']:
if 'contentType' not in msg:
msg['contentType'] = 'text/link'
if hasattr(self.proto[self.scheme], 'symlink'):
logger.debug("message is to link %s to: %s" % (new_file, msg['fileOp']['link']))
if not self.o.dry_run:
Expand Down

0 comments on commit 927c0f9

Please sign in to comment.