ssh: support reflinks and hardlinks

This commit is contained in:
Mr. Outis
2019-08-23 21:20:50 -05:00
parent 110da0c366
commit f4563bdd85
2 changed files with 15 additions and 4 deletions
+7 -4
View File
@@ -50,9 +50,7 @@ class RemoteSSH(RemoteBASE):
# We use conservative setting of 4 instead to not exhaust max sessions.
CHECKSUM_JOBS = 4
# XXX: Friendly reminder to add "reflink" to the default types
# after is implemented
DEFAULT_CACHE_TYPES = ["symlink", "copy"]
DEFAULT_CACHE_TYPES = ["reflink, copy"]
def __init__(self, repo, config):
super(RemoteSSH, self).__init__(repo, config)
@@ -323,7 +321,12 @@ class RemoteSSH(RemoteBASE):
@classmethod
def _get_link_method(cls, link_type, ssh):
CACHE_TYPE_MAP = {"copy": ssh.cp, "symlink": ssh.symlink}
CACHE_TYPE_MAP = {
"copy": ssh.cp,
"symlink": ssh.symlink,
"reflink": ssh.reflink,
"hardlink": ssh.hardlink,
}
try:
return CACHE_TYPE_MAP[link_type]
+8
View File
@@ -294,3 +294,11 @@ class SSHConnection:
def symlink(self, *args, **kwargs):
return self.sftp.symlink(*args, **kwargs)
def reflink(self, src, dest):
self.makedirs(posixpath.dirname(dest))
self.execute("cp --reflink {} {}".format(src, dest))
def hardlink(self, src, dest):
self.makedirs(posixpath.dirname(dest))
self.execute("ln {} {}".format(src, dest))