From c30710d70bb629c979975a92e57179af3fb2efa6 Mon Sep 17 00:00:00 2001 From: Michael Behrisch Date: Sat, 21 Dec 2024 12:03:03 +0100 Subject: [PATCH] using wsl if we are on windows and no native rsync is available #43 --- sysrsync/command_maker.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sysrsync/command_maker.py b/sysrsync/command_maker.py index 5849948..54265de 100644 --- a/sysrsync/command_maker.py +++ b/sysrsync/command_maker.py @@ -1,6 +1,7 @@ """Generates the rsync command.""" import os import os.path +import shutil from typing import Iterable, List, Optional from sysrsync.exceptions import RemotesError @@ -67,9 +68,13 @@ def get_rsync_command(source: str, if options is None: options = [] - return ['rsync', - *options, - *rsh, - source, - destination, - *exclusions_options] + rsync_cmd = ['rsync', + *options, + *rsh, + source, + destination, + *exclusions_options] + if os.name == 'nt' and not shutil.which(rsync_cmd[0]) and shutil.which('wsl'): + rsync_cmd = ['wsl'] + rsync_cmd + + return rsync_cmd