Commit 507ca276 authored by Rudel Fankep's avatar Rudel Fankep
Browse files

security to delete

parent f2e0e504
......@@ -347,36 +347,40 @@ def download(args):
def delete(args):
if args.database in data.keys():
if args.tool in data[args.database]['tool'].keys() or args.tool == "raw":
if args.place == 'local':
version = get_local_json_version(args)
dbman_dir = get_local_databases_directory(args)
directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version))
if os.path.isdir(directory_to_delete):
shutil.rmtree(directory_to_delete)
metadata = get_local_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_local_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
elif args.place == 's3':
version = get_remote_json_version(args)
web_store = get_remote_databases_directory(args)
web_file = path_maker(web_store, get_tar_filename(args, version))
if web_file in get_remote_files():
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/delete_remote_file.sh"), web_file])
metadata = get_remote_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_remote_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + web_store)
frage = input('Do you want to continue (Y/N)? ')
if frage.lower() == 'y':
if args.place == 'local':
version = get_local_json_version(args)
dbman_dir = get_local_databases_directory(args)
directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version))
if os.path.isdir(directory_to_delete):
shutil.rmtree(directory_to_delete)
metadata = get_local_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_local_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
elif args.place == 's3':
version = get_remote_json_version(args)
web_store = get_remote_databases_directory(args)
web_file = path_maker(web_store, get_tar_filename(args, version))
if web_file in get_remote_files():
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/delete_remote_file.sh"), web_file])
metadata = get_remote_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_remote_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print('delete canceled')
else:
print('Tool error. There are following possibility: {}'.format([tool for tool in data[args.database]['tool'].keys()]))
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment