Skip to content

Commit

Permalink
sftp: make move across drives possible
Browse files Browse the repository at this point in the history
Fix #2704
  • Loading branch information
Mr. Outis committed Nov 1, 2019
1 parent d932405 commit ab1ead8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dvc/remote/ssh/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,17 @@ def download(self, src, dest, no_progress_bar=False, progress_title=None):
self.sftp.get(src, dest, callback=pbar.update_to)

def move(self, src, dst):
"""Use `SFTP RENAME` operation when possible, otherwise,
fallback to copy and remove, since the former one doesn't
work across drives.
"""
self.makedirs(posixpath.dirname(dst))
self.sftp.rename(src, dst)

try:
self.sftp.rename(src, dst)
except OSError:
self.copy(src, dst)
self.remove(src)

def upload(self, src, dest, no_progress_bar=False, progress_title=None):
self.makedirs(posixpath.dirname(dest))
Expand Down

0 comments on commit ab1ead8

Please sign in to comment.