def _send_hook(self, action): source = None destination = None if action in ('move', 'copy'): # if provider can't intra_move or copy, then the celery task will take care of logging if not getattr(self.provider, 'can_intra_' + action)( self.dest_provider, self.path): return source = LogPayload(self.resource, self.provider, path=self.path) destination = LogPayload( self.dest_resource, self.dest_provider, metadata=self.dest_meta, ) elif action in ('create', 'create_folder', 'update'): source = LogPayload(self.resource, self.provider, metadata=self.metadata) elif action in ('delete', 'download_file', 'download_zip'): source = LogPayload(self.resource, self.provider, path=self.path) else: return remote_logging.log_file_action( action, source=source, destination=destination, api_version='v1', request=remote_logging._serialize_request(self.request), bytes_downloaded=self.bytes_downloaded, bytes_uploaded=self.bytes_uploaded, )
async def copy(src_bundle, dest_bundle, request=None, start_time=None, **kwargs): request = request or {} start_time = start_time or time.time() src_path = src_bundle.pop('path') src_provider = utils.make_provider(**src_bundle.pop('provider'), is_celery_task=True) dest_path = dest_bundle.pop('path') dest_provider = utils.make_provider(**dest_bundle.pop('provider'), is_celery_task=True) logger.info('Starting copying {!r}, {!r} to {!r}, {!r}'.format( src_path, src_provider, dest_path, dest_provider)) metadata, errors = None, [] try: metadata, created = await src_provider.copy(dest_provider, src_path, dest_path, **kwargs) except Exception as e: logger.error('Copy failed with error {!r}'.format(e)) errors = [e.__repr__()] raise # Ensure sentry sees this else: logger.info('Copy succeeded') dest_path = WaterButlerPath.from_metadata(metadata) finally: source = LogPayload(src_bundle['nid'], src_provider, path=src_path) destination = LogPayload(dest_bundle['nid'], dest_provider, path=dest_path, metadata=metadata) await remote_logging.wait_for_log_futures( 'copy', source=source, destination=destination, start_time=start_time, errors=errors, request=request, api_version='celery', ) return metadata, created
def _send_hook(self, action, metadata): source = LogPayload(self.json['source']['nid'], self.source_provider, path=self.json['source']['path']) destination = LogPayload(self.json['destination']['nid'], self.destination_provider, metadata=metadata) remote_logging.log_file_action( action, source=source, destination=destination, api_version='v0', request=remote_logging._serialize_request(self.request), bytes_downloaded=self.bytes_downloaded, bytes_uploaded=self.bytes_uploaded)
def _send_hook(self, action, metadata=None, path=None): source = LogPayload(self.arguments['nid'], self.provider, metadata=metadata, path=path) remote_logging.log_file_action( action, source=source, api_version='v0', request=remote_logging._serialize_request(self.request), bytes_downloaded=self.bytes_downloaded, bytes_uploaded=self.bytes_uploaded)