renamed that function again to make it even more clear what it does
parent
639e3ed9ca
commit
8864947575
10
filetags.py
10
filetags.py
|
@ -126,7 +126,7 @@ def get_hashes_by_tag(storage_directory, tag):
|
|||
|
||||
return file_hashes
|
||||
|
||||
def file_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress):
|
||||
def file_hash_or_path_is_known_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_hash_or_path_is_hash(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_known_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_hash_or_path_is_hash(storage_directory, file_hash_or_path, compress):
|
||||
if hash_allowed and file_hash_or_path_is_known_hash(storage_directory, file_hash_or_path, compress):
|
||||
file_hash = file_hash_or_path
|
||||
print("Hash for file in storage: "+file_hash)
|
||||
else:
|
||||
file_hash = calculate_file_hash(checksum_algorithm, file_hash_or_path)
|
||||
if file_hash_or_path_is_hash(storage_directory, file_hash, compress):
|
||||
if file_hash_or_path_is_known_hash(storage_directory, file_hash, 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_hash_or_path_is_hash(storage_directory, file_tags_or_hash[0], compress):
|
||||
if file_hash_or_path_is_known_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)
|
||||
|
|
Loading…
Reference in New Issue