Add ability to clear working directory to solve aborted downloads causing problems

This commit is contained in:
Graham R Pugh 2020-06-23 14:58:45 +02:00
parent 7fddca85bb
commit 3a1cbeb736

View File

@ -30,6 +30,7 @@ import argparse
import gzip import gzip
import os import os
import plistlib import plistlib
import shutil
import subprocess import subprocess
import sys import sys
import xattr import xattr
@ -649,6 +650,11 @@ def main():
"10G of available space. Defaults to current working " "10G of available space. Defaults to current working "
"directory.", "directory.",
) )
parser.add_argument(
"--clear",
action="store_true",
help="Clear the working directory to ensure a new download.",
)
parser.add_argument( parser.add_argument(
"--compress", "--compress",
action="store_true", action="store_true",
@ -916,14 +922,22 @@ def main():
and not args.build and not args.build
and not args.current and not args.current
and not args.validate and not args.validate
and not args.list
): ):
print("No valid build found for this hardware") print("No valid build found for this hardware")
exit(0) exit(0)
# clear content directory in workdir if requested
if args.clear:
print(
"Removing existing content from working directory '%s'...\n" % args.workdir
)
shutil.rmtree("%s/content" % args.workdir)
# Output a plist of available updates and quit if list option chosen # Output a plist of available updates and quit if list option chosen
if args.list: if args.list:
write_plist(pl, output_plist) write_plist(pl, output_plist)
print("\n" "Valid seeding programs are: %s" % ", ".join(get_seeding_programs())) print("Valid seeding programs are: %s" % ", ".join(get_seeding_programs()))
exit(0) exit(0)
# check for validity of specified build if argument supplied # check for validity of specified build if argument supplied