Example #1
0
def should_upload(filepath, item, force_upload):
    """
    Return true if the file at filepath should be uploaded, false otherwise.

    We upload if any of the following are true:
     - force_upload is True
     - the remote item doesn't exist
     - the checksums differ and the local file is newer
    """
    if force_upload or not item:
        return True

    local_mtime = mtime_as_datetime(filepath)
    remote_mtime = s3time_as_datetime(item.last_modified)
    files_differ = not md5_matches(filepath, get_s3item_md5(item))
    return files_differ and local_mtime >= remote_mtime
Example #2
0
def should_upload(filepath, item, force_upload):
    """
    Return true if the file at filepath should be uploaded, false otherwise.

    We upload if any of the following are true:
     - force_upload is True
     - the remote item doesn't exist
     - the checksums differ and the local file is newer
    """
    if force_upload or not item:
        return True

    local_mtime = mtime_as_datetime(filepath)
    remote_mtime = s3time_as_datetime(item.last_modified)
    files_differ = not md5_matches(filepath, get_s3item_md5(item))
    return files_differ and local_mtime >= remote_mtime
Example #3
0
def should_download(item, filepath, force_download):
    """
    Return true if item should be downloaded to filepath, false otherwise.

    We download if any of the following are true:
     - force_download is True
     - the file doesn't exist
     - the checksums differ and the remote file is newer
    """
    if force_download or not os.path.exists(filepath):
        return True

    local_mtime = mtime_as_datetime(filepath)
    remote_mtime = s3time_as_datetime(item.last_modified)
    files_differ = not md5_matches(filepath, get_s3item_md5(item))
    return files_differ and remote_mtime >= local_mtime
Example #4
0
def should_download(item, filepath, force_download):
    """
    Return true if item should be downloaded to filepath, false otherwise.

    We download if any of the following are true:
     - force_download is True
     - the file doesn't exist
     - the checksums differ and the remote file is newer
    """
    if force_download or not os.path.exists(filepath):
        return True

    local_mtime = mtime_as_datetime(filepath)
    remote_mtime = s3time_as_datetime(item.last_modified)
    files_differ = not md5_matches(filepath, get_s3item_md5(item))
    return files_differ and remote_mtime >= local_mtime