diff --git a/tailbone/views/batch.py b/tailbone/views/batch.py index b50c7d55..ce15223c 100644 --- a/tailbone/views/batch.py +++ b/tailbone/views/batch.py @@ -531,7 +531,18 @@ class BatchCrud(BaseCrud): # transaction binding etc. session = RatSession() batch = session.query(self.batch_class).get(batch_uuid) - self.refresh_data(session, batch, progress=progress) + try: + self.refresh_data(session, batch, progress=progress) + except Exception as error: + session.rollback() + log.exception("refreshing data for batch failed: {0}".format(batch)) + session.close() + progress.session.load() + progress.session['error'] = True + progress.session['error_msg'] = "Data refresh failed: {0}".format(error) + progress.session.save() + return + session.commit() session.refresh(batch) session.close() @@ -572,13 +583,13 @@ class FileBatchCrud(BatchCrud): """ refreshable = True - def pre_crud(self, batch): + def post_create_url(self, form): """ - Force refresh if batch has yet to be cognized. + Redirect to refresh batch after creating a batch. """ - if not self.creating and not batch.cognized: - return HTTPFound(location=self.request.route_url( - '{0}.refresh'.format(self.route_prefix), uuid=batch.uuid)) + batch = form.fieldset.model + Session.flush() + return self.refresh_url(batch.uuid) @property def upload_dir(self):