Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
b629de8a
Commit
b629de8a
authored
Sep 09, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into zope4py2
parents
44ce2448
34f4ae37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
...plateItem/portal_components/document.erp5.FTPConnector.py
+14
-3
No files found.
bt5/erp5_web_service/DocumentTemplateItem/portal_components/document.erp5.FTPConnector.py
View file @
b629de8a
...
...
@@ -27,6 +27,8 @@
#
##############################################################################
import
posixpath
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
...
...
@@ -102,15 +104,24 @@ class FTPConnector(XMLObject):
def
putFile
(
self
,
filename
,
data
,
remotepath
=
'.'
,
confirm
=
True
):
""" Send file to the remote server """
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
:
if
self
.
isUseTemporaryFileOnWrite
():
temp_filename
=
'_%s.tmp'
%
filename
# Simulation transaction system
conn
.
writeFile
(
remotepath
,
temp_filename
,
data
,
confirm
=
confirm
)
self
.
activate
(
activity
=
'SQLQueue'
).
renameFile
(
'%s/%s'
%
(
remotepath
,
temp_filename
),
'%s/%s'
%
(
remotepath
,
filename
))
self
.
activate
(
activity
=
'SQLQueue'
).
renameFile
(
posixpath
.
join
(
remotepath
,
temp_filename
),
posixpath
.
join
(
remotepath
,
filename
)
)
else
:
conn
.
writeFile
(
remotepath
,
'%s'
%
filename
,
data
,
confirm
=
confirm
)
conn
.
writeFile
(
remotepath
,
filename
,
data
,
confirm
=
confirm
)
finally
:
conn
.
logout
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment