INNER CODE UNIT · Python
has_file_changed
kblin/ncbi-genome-download · ncbi_genome_download/core.py:574
def has_file_changed(directory, checksums, filetype='genbank'):
"""Check if the checksum of a given file has changed."""
pattern = NgdConfig.get_fileending(filetype)
filename, expected_checksum = get_name_and_checksum(checksums, pattern)
full_filename = os.path.join(directory, filename)
# if file doesn't exist, it has changed
if not os.path.isfile(full_filename):
return True
actual_checksum = md5sum(full_filename)
return expected_checksum != actual_checksum
def need_to_create_symlink(directory, checksums, filetype, symlink_path):
"""Check if we need to create a symlink for an existing file."""
# If we don't have a symlink path, we don't need to create a symlink
if symlink_path is None:
return False