Esempio n. 1
0
def _parity_create_files(self, name, credentials, settings):
    path = os.path.join(osf_settings.FILE_PATH_COMPLETE, name)
    loop = asyncio.get_event_loop()
    with utils.RetryUpload(self):
        parity_paths = utils.create_parity_files(
            path,
            redundancy=osf_settings.PARITY_REDUNDANCY,
        )
        if not parity_paths:
            #create_parity_files will return [] for empty files
            return
        futures = [asyncio.async(_upload_parity(each, credentials, settings)) for each in parity_paths]
Esempio n. 2
0
def _push_file_archive(self, local_path, version_id, callback_url, credentials,
                       settings):
    _, name = os.path.split(local_path)
    with utils.RetryUpload(self):
        vault = get_vault(credentials, settings)
        try:
            glacier_id = vault.upload_archive(local_path, description=name)
        except UnexpectedHTTPResponseError as error:
            # Glacier doesn't allow empty files; catch this exception but raise
            # other errors
            if error.status == 400:
                payload = json.loads(error.body.decode('utf-8'))
                if payload.get('message') == 'Invalid Content-Length: 0':
                    return
            raise
    metadata = {
        'vault': vault.name,
        'archive': glacier_id,
    }
    _push_archive_complete.delay(version_id, callback_url, metadata)