renamed function file_is_in_storage to file_hash_or_path_is_hash to better reflect what it does
parent
f66573b1ae
commit
66aec7ae75
10
filetags.py
10
filetags.py
|
@ -126,7 +126,7 @@ def get_hashes_by_tag(storage_directory, tag):
|
||||||
|
|
||||||
return file_hashes
|
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=""
|
suffix=""
|
||||||
if compress:
|
if compress:
|
||||||
suffix=".xz"
|
suffix=".xz"
|
||||||
|
@ -301,19 +301,19 @@ if __name__ == "__main__":
|
||||||
hash_allowed=True
|
hash_allowed=True
|
||||||
if 'file' in command:
|
if 'file' in command:
|
||||||
hash_allowed=False
|
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("Unknown file!", file=sys.stderr)
|
||||||
print(USAGE, file=sys.stderr)
|
print(USAGE, file=sys.stderr)
|
||||||
sys.exit(PATH_ERROR)
|
sys.exit(PATH_ERROR)
|
||||||
|
|
||||||
tags = sys.argv[4:]
|
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
|
file_hash = file_hash_or_path
|
||||||
print("File already in storage.")
|
print("File already in storage.")
|
||||||
else:
|
else:
|
||||||
file_hash = calculate_file_hash(checksum_algorithm, file_hash_or_path)
|
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.")
|
print("File already in storage.")
|
||||||
#this assumes that the storage directory has not been tampered with or corrupted, FIXME!
|
#this assumes that the storage directory has not been tampered with or corrupted, FIXME!
|
||||||
if 'move' in command:
|
if 'move' in command:
|
||||||
|
@ -367,7 +367,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
file_tags_or_hash = sys.argv[3:]
|
file_tags_or_hash = sys.argv[3:]
|
||||||
if not 'tags' in command:
|
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])
|
tags = get_tags_by_hash(storage_directory, file_tags_or_hash[0])
|
||||||
print("Tags for file:")
|
print("Tags for file:")
|
||||||
print(tags)
|
print(tags)
|
||||||
|
|
Loading…
Reference in New Issue