def get_timeout(filesize, add=0):
    """
    Get a proper time-out limit based on the file size.

    :param filesize: file size (int).
    :param add: optional additional time to be added [s] (int)
    :return: time-out in seconds (int).
    """
    timeout_max = 3 * 3600
    timeout_min = 300
    timeout = timeout_min + int(filesize / 500000.0) + add
    return min(timeout, timeout_max)
