Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jooleer committed May 21, 2023
1 parent 17ab75d commit 437ac27
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions folder_hash_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def generate_file_hash(file_path, hash_algorithm="CRC32"):
file_hash = hashlib.md5(file_data).hexdigest()
elif hash_algorithm == "SHA256":
file_hash = hashlib.sha256(file_data).hexdigest()

return file_hash

# get a list of all files in a folder and its subfolders
Expand All @@ -54,13 +53,15 @@ def get_files_amount(folder_path):
def folder_generate_hashes(folder_path):
folder_hashes = {}
for file_path in get_all_files(folder_path):

# in case program is not run directly
if __name__ == '__main__':
file_hash = generate_file_hash(file_path, hash_algorithm)
else:
file_hash = generate_file_hash(file_path, "CRC32")
relative_file_path = os.path.relpath(file_path, folder_path)
folder_hashes[relative_file_path] = file_hash

# in case program is not run directly
if __name__ == '__main__':
if(args.verbose):
Expand All @@ -75,7 +76,6 @@ def seconds_to_minutes(seconds):
hours, minutes = divmod(minutes, 60)
return hours, minutes, seconds


def search_missing_files(directory, folder_hashes):
files_missing = 0
for file_path in get_all_files(directory):
Expand All @@ -94,7 +94,6 @@ def search_missing_files(directory, folder_hashes):
print(bcolors.OKGREEN + f"No files missing from directory: {directory}" + bcolors.ENDC)
return files_missing


def main():
files_completed = 0
files_errors = 0
Expand Down Expand Up @@ -187,7 +186,6 @@ def main():
logging.info(f"{files_errors} file(s) FAILED")
logging.info(f"{files_missing_total} file(s) MISSING")


if __name__ == '__main__':
parser = argparse.ArgumentParser(
prog='folder_hash_compare.py',
Expand Down

0 comments on commit 437ac27

Please sign in to comment.