summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/mpremote/mpremote/commands.py12
-rw-r--r--tools/mpremote/mpremote/main.py7
2 files changed, 14 insertions, 5 deletions
diff --git a/tools/mpremote/mpremote/commands.py b/tools/mpremote/mpremote/commands.py
index 1f3a89a84..2b1acea43 100644
--- a/tools/mpremote/mpremote/commands.py
+++ b/tools/mpremote/mpremote/commands.py
@@ -184,7 +184,7 @@ def do_filesystem_cp(state, src, dest, multiple, check_hash=False):
f.write(data)
-def do_filesystem_recursive_cp(state, src, dest, multiple):
+def do_filesystem_recursive_cp(state, src, dest, multiple, check_hash):
# Ignore trailing / on both src and dest. (Unix cp ignores them too)
src = src.rstrip("/" + os.path.sep + (os.path.altsep if os.path.altsep else ""))
dest = dest.rstrip("/" + os.path.sep + (os.path.altsep if os.path.altsep else ""))
@@ -257,7 +257,7 @@ def do_filesystem_recursive_cp(state, src, dest, multiple):
# If no directories were encountered then we must have just had a file.
if not dirs:
- return do_filesystem_cp(state, src, dest, multiple)
+ return do_filesystem_cp(state, src, dest, multiple, check_hash)
def _mkdir(a, *b):
try:
@@ -287,7 +287,7 @@ def do_filesystem_recursive_cp(state, src, dest, multiple):
else:
dest_path_joined = os.path.join(dest, *dest_path_split)
- do_filesystem_cp(state, src_path_joined, dest_path_joined, multiple=False, check_hash=True)
+ do_filesystem_cp(state, src_path_joined, dest_path_joined, False, check_hash)
def do_filesystem(state, args):
@@ -352,9 +352,11 @@ def do_filesystem(state, args):
print(digest.hex())
elif command == "cp":
if args.recursive:
- do_filesystem_recursive_cp(state, path, cp_dest, len(paths) > 1)
+ do_filesystem_recursive_cp(
+ state, path, cp_dest, len(paths) > 1, not args.force
+ )
else:
- do_filesystem_cp(state, path, cp_dest, len(paths) > 1)
+ do_filesystem_cp(state, path, cp_dest, len(paths) > 1, not args.force)
except FileNotFoundError as er:
raise CommandError("{}: {}: No such file or directory.".format(command, er.args[0]))
except IsADirectoryError as er:
diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py
index c5e73b1cc..8c0a6cd22 100644
--- a/tools/mpremote/mpremote/main.py
+++ b/tools/mpremote/mpremote/main.py
@@ -184,6 +184,13 @@ def argparse_filesystem():
_bool_flag(cmd_parser, "recursive", "r", False, "recursive copy (for cp command only)")
_bool_flag(
cmd_parser,
+ "force",
+ "f",
+ False,
+ "force copy even if file is unchanged (for cp command only)",
+ )
+ _bool_flag(
+ cmd_parser,
"verbose",
"v",
None,