Browse code

Fix error in "-m" argument handling when "-c" is not given

Lorenz Hüdepohl authored on 03/11/2017 15:20:35
Showing 1 changed files
... ...
@@ -35,8 +35,8 @@ parser.add_argument('-c', '--cache-dir', metavar="DIR",
35 35
                          'then rsync that to the remote host. With that, one can resume '
36 36
                          'a partially sent file without starting over')
37 37
 
38
-parser.add_argument('-m', '--min-cache-size', default="50M",
39
-                    help='Minimum (estimated) size of stream to use the cache-dir funcitonality')
38
+parser.add_argument('-m', '--min-cache-size',
39
+                    help='Minimum (estimated) size of stream to use the cache-dir funcitonality, default 50M')
40 40
 
41 41
 parser.add_argument('-v', '--verbose', action="append_const", const=1,
42 42
                     help='Echo the commands that are issued. Two -v pass a -v along to the zfs send/recv commands')
... ...
@@ -48,11 +48,11 @@ parser.add_argument('-n', '--dry-run', action="store_true",
48 48
 args = parser.parse_args()
49 49
 args.verbose = sum(args.verbose) if args.verbose is not None else 0
50 50
 
51
-no_defaults_parser = argparse.ArgumentParser(parents=(parser,), argument_default=None, add_help=False)
52
-no_defaults_args = no_defaults_parser.parse_args()
53
-if not args.cache_dir and no_defaults_args.min_cache_size is not None:
51
+if not args.cache_dir and args.min_cache_size is not None:
54 52
     print("Cannot specify -m/--min-cache-size without -c/--cache-dir", file=sys.stderr)
55 53
     raise SystemExit(1)
54
+elif args.cache_dir and args.min_cache_size is None:
55
+    args.min_cache_size = "50M"
56 56
 
57 57
 def check_returncode(proc):
58 58
     if not proc.returncode == 0: