aborts writing if not enough space on drive to write

def write_quota(outbytes: int, outfn: Path) -> Union[None, int]:
    """
    aborts writing if not enough space on drive to write
    """
    if not outfn:
        return None

    anch = Path(outfn).resolve().anchor
    freeout = shutil.disk_usage(anch).free

    if freeout < 10 * outbytes:
        raise IOError(f'out of disk space on {anch}.'
                      '{freeout/1e9} GB free, wanting to write {outbytes/1e9} GB.')

    return freeout