wormhole receive-file: add --overwrite

This commit is contained in:
Brian Warner 2015-03-25 16:31:35 -07:00
parent 717bfa3b0b
commit 883cacf903
2 changed files with 7 additions and 1 deletions

View File

@ -65,7 +65,7 @@ def receive_file(args):
record_pipe.send_record("bad filename\n")
record_pipe.close()
return 1
if os.path.exists(target):
if os.path.exists(target) and not args.overwrite:
print("Error: refusing to overwrite existing file %s" % (filename,))
record_pipe.send_record("file already exists\n")
record_pipe.close()

View File

@ -52,6 +52,12 @@ p.add_argument("-o", "--output-file", default=None, metavar="FILENAME",
The file to create, overriding the filename suggested by the
sender"""),
)
p.add_argument("--overwrite", action="store_true",
help=dedent("""\
Allow the output file to be overwritten. By default, if the
output file already exists, the program will refuse to
overwrite it."""),
)
p.add_argument("code", nargs="?", default=None, metavar="[CODE]",
help=dedent("""\
The magic-wormhole code, from the sender. If omitted, the