Commit b629de8a authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py2

parents 44ce2448 34f4ae37
Pipeline #23451 failed with stage
in 0 seconds
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
# #
############################################################################## ##############################################################################
import posixpath
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
...@@ -102,15 +104,24 @@ class FTPConnector(XMLObject): ...@@ -102,15 +104,24 @@ class FTPConnector(XMLObject):
def putFile(self, filename, data, remotepath='.', confirm=True): def putFile(self, filename, data, remotepath='.', confirm=True):
""" Send file to the remote server """ """ Send file to the remote server """
conn = self.getConnection() conn = self.getConnection()
# This API is misleading, and in reality filename often contains a path.
# So let's use python posixpath API to try to reconstruct the path in a
# robust way (ie: what if remotepath is './a' and filename is 'b/c.txt' ?),
# and recompute the correct remotepath and filename
remotepath, filename = posixpath.split(
posixpath.join(remotepath, filename)
)
try: try:
if self.isUseTemporaryFileOnWrite(): if self.isUseTemporaryFileOnWrite():
temp_filename = '_%s.tmp' % filename temp_filename = '_%s.tmp' % filename
# Simulation transaction system # Simulation transaction system
conn.writeFile(remotepath, temp_filename, data, confirm=confirm) conn.writeFile(remotepath, temp_filename, data, confirm=confirm)
self.activate(activity='SQLQueue').renameFile('%s/%s' % (remotepath, temp_filename), self.activate(activity='SQLQueue').renameFile(
'%s/%s' % (remotepath, filename)) posixpath.join(remotepath, temp_filename),
posixpath.join(remotepath, filename)
)
else: else:
conn.writeFile(remotepath, '%s' % filename, data, confirm=confirm) conn.writeFile(remotepath, filename, data, confirm=confirm)
finally: finally:
conn.logout() conn.logout()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment