diff --git a/utils/flees-manager.py b/utils/flees-manager.py index 209e916..01f947b 100755 --- a/utils/flees-manager.py +++ b/utils/flees-manager.py @@ -242,14 +242,17 @@ def remove_share(shares,config,opts): print("Removing share: %s"%( name, )) print(json.dumps(share_, indent = 2, sort_keys = True)) - shares = [share for share in shares if share['name'] != name] + if opts.write: + shares = [share for share in shares if share['name'] != name] - shares_file = os.path.join(config['__root_path__'], opts.shares_file) - print("creating backup %s"%(shares_file+".bkp",)) - copyfile(shares_file, shares_file+".bkp") - with open(shares_file,'wt') as fp: - json.dump(shares, fp, indent = 2, sort_keys = True) - print("Removed %s from %s"%(name, shares_file)) + shares_file = os.path.join(config['__root_path__'], opts.shares_file) + print("creating backup %s"%(shares_file+".bkp",)) + copyfile(shares_file, shares_file+".bkp") + with open(shares_file,'wt') as fp: + json.dump(shares, fp, indent = 2, sort_keys = True) + print("Removed %s from %s"%(name, shares_file)) + else: + print("Share was not actually removed. Use -w to rewrite shares file.") def print_rest_api(shares, config, opts): @@ -371,6 +374,9 @@ def parse_options(): ## Remove parser_remove = subparsers.add_parser('remove', help = "Remove a share") parser_remove.add_argument(dest="name") + parser_remove.add_argument('-w','--write', action="store_true", dest="write", default = False, + help = "Write changes to the shares.json file" + ) ## Add parser_add = subparsers.add_parser('add', help = "Add a share") parser_add.add_argument('-n','--name', action="store", dest="name", required = True)