import hashlib
import io


def calculate_file_checksum(path):
    """
    Calculate the MD5 sum for a file:
    Read chunks of a file and update the hasher.
    Returns the hex digest of the md5 hash.
    """
    hasher = hashlib.md5()
    with io.FileIO(path, 'r') as fp:
        while True:
            buf = fp.read(65536)
            if not buf:
                break
            hasher.update(buf)
    return hasher.hexdigest()