Skip to content

Commit a031efe

Browse files
committed
fixed bug in sftpclone with windows backslashes; fixed by replacing backslashes with forward slashes which python can handle correctly on both windows as linux
1 parent b866243 commit a031efe

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

ev3devcmd/sftpclone.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ def path_join(*args):
5656
Makes sure to join paths of the same type (bytes).
5757
"""
5858
args = (paramiko.py3compat.u(arg) for arg in args)
59-
return os.path.join(*args)
59+
result=os.path.join(*args)
60+
# convert windows backslashes to forward slashes, because sftp expects forward slashes as directory separator
61+
return result.replace("\\","/")
62+
6063

6164

6265
def parse_username_password_hostname(remote_url):
@@ -423,7 +426,6 @@ def check_for_deletion(self, relative_path=None):
423426

424427
for remote_st in self.sftp.listdir_attr(remote_path):
425428
r_lstat = self.sftp.lstat(path_join(remote_path, remote_st.filename))
426-
427429
inner_remote_path = path_join(remote_path, remote_st.filename)
428430
inner_local_path = path_join(local_path, remote_st.filename)
429431

@@ -593,6 +595,11 @@ def run(self):
593595
"""Run the sync.
594596
595597
Confront the local and the remote directories and perform the needed changes."""
598+
599+
# In sftpclone we always use forward slashes; for both windows as linux paths
600+
# So we need to convert any windows forward slashes into back slashes in the exclude list.
601+
self.exclude_list= [ item.replace("\\","/") for item in self.exclude_list]
602+
596603
try:
597604
if self.delete:
598605
# First check for items to be removed

0 commit comments

Comments
 (0)