renamed function file_is_in_storage to file_hash_or_path_is_hash to better reflect what it does

master
BodgeMaster 2021-12-12 10:06:26 +01:00
parent f66573b1ae
commit 66aec7ae75
1 changed files with 5 additions and 5 deletions

View File

@ -126,7 +126,7 @@ def get_hashes_by_tag(storage_directory, tag):
return file_hashes
def file_is_in_storage(storage_directory, file_hash_or_path, compress):
def file_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress):
suffix=""
if compress:
suffix=".xz"
@ -301,19 +301,19 @@ if __name__ == "__main__":
hash_allowed=True
if 'file' in command:
hash_allowed=False
if not any([hash_allowed and file_is_in_storage(storage_directory, file_hash_or_path, compress), os.path.isfile(file_hash_or_path)]):
if not any([hash_allowed and file_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress), os.path.isfile(file_hash_or_path)]):
print("Unknown file!", file=sys.stderr)
print(USAGE, file=sys.stderr)
sys.exit(PATH_ERROR)
tags = sys.argv[4:]
if hash_allowed and file_is_in_storage(storage_directory, file_hash_or_path, compress):
if hash_allowed and file_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress):
file_hash = file_hash_or_path
print("File already in storage.")
else:
file_hash = calculate_file_hash(checksum_algorithm, file_hash_or_path)
if file_is_in_storage(storage_directory, file_hash_or_path, compress):
if file_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress):
print("File already in storage.")
#this assumes that the storage directory has not been tampered with or corrupted, FIXME!
if 'move' in command:
@ -367,7 +367,7 @@ if __name__ == "__main__":
file_tags_or_hash = sys.argv[3:]
if not 'tags' in command:
if file_is_in_storage(storage_directory, file_tags_or_hash[0], compress):
if file_hash_or_path_is_hash(storage_directory, file_tags_or_hash[0], compress):
tags = get_tags_by_hash(storage_directory, file_tags_or_hash[0])
print("Tags for file:")
print(tags)