Commit 8196b043 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.ConnectionPlugin.SFTPConnection: Make file size check conditional.

In some cases, listing files is disallowed. Allow caller to disable
paramiko's default-enabled file size check to support these cases.
parent 5bb3a8dc
......@@ -99,16 +99,16 @@ class FTPConnector(XMLObject):
finally:
conn.logout()
def putFile(self, filename, data, remotepath='.'):
def putFile(self, filename, data, remotepath='.', confirm=True):
""" Send file to the remote server """
conn = self.getConnection()
try:
if self.isUseTemporaryFileOnWrite():
# Simulation transaction system
conn.writeFile(remotepath, '%s.tmp' % filename, data)
conn.writeFile(remotepath, '%s.tmp' % filename, data, confirm=confirm)
self.activate(activity='SQLQueue').renameFile('%s/%s.tmp' % (remotepath, filename),
'%s/%s' % (remotepath, filename))
else:
conn.writeFile(remotepath, '%s' % filename, data)
conn.writeFile(remotepath, '%s' % filename, data, confirm=confirm)
finally:
conn.logout()
9
\ No newline at end of file
10
\ No newline at end of file
......@@ -104,14 +104,14 @@ class SFTPConnection:
raise SFTPError(str(msg) + ' while changing to dir -%r-' % (schema.path,))
return self
def writeFile(self, path, filename, data):
def writeFile(self, path, filename, data, confirm=True):
"""
Write data in provided filepath
"""
filepath = os.path.join(path, filename)
serialized_data = Binary(str(data))
try:
self.conn.putfo(StringIO(str(serialized_data)), filepath)
self.conn.putfo(StringIO(str(serialized_data)), filepath, confirm=confirm)
except error, msg:
raise SFTPError(str(msg) + ' while writing file %s on %s' % (filepath, path, self.url))
......
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