from pathlib import Path
import hashlib


def get_md5_from_file(filepath, chunk_size=8196):
    """
    Gets the MD5 hash of a file.
    :param filepath:
        The path to the file.
    :param chunk_size:
        An integer representing the number of bytes of data to get
        in a single iteration. Defaults to 8196.
    :returns:
        The MD5 hash of the file, or None if it doesn't exist.
    """

    filepath = Path(filepath)
    if not filepath.exists(): return

    h = hashlib.md5()
    with open(filepath, 'rb') as file:
        chunk = 0
        while chunk != b'':
            chunk = file.read(chunk_size)
            h.update(chunk)

    return h.hexdigest()