Skip to content

Commit

Permalink
rebuild_transfer_backlog: fix bag error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Apr 4, 2019
1 parent f53d4fd commit 60b6c80
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ def delete_indexes(self, es_client, indexes):
"""Delete search indexes."""
self.stdout.write(
"Deleting all transfers and transfer files "
'in the "transfers" and "transferfiles" indexes ...'
'in the "transfers" and "transferfiles" indexes...'
)
time.sleep(3) # Time for the user to panic and kill the process.
es_client.indices.delete(",".join(indexes), ignore=404)

def create_indexes(self, es_client, indexes):
"""Create search indexes."""
self.stdout.write("Creating indexes ...")
self.stdout.write("Creating indexes...")
elasticSearchFunctions.create_indexes_if_needed(es_client, indexes)

def populate_data(self, es_client, transfer_backlog_dir):
Expand All @@ -159,11 +159,9 @@ def populate_data(self, es_client, transfer_backlog_dir):
processes=multiprocessing.cpu_count(), completeness_only=True
)
except bagit.BagError:
self.warning(
"Skipping transfer {} - not a valid bag!".format(transfer_dir)
)
bag = None
transfer_uuid = transfer_dir.name[-36:]
if "External-Identifier" in bag.info:
if bag and "External-Identifier" in bag.info:
self.info(
"Importing self-describing transfer {}.".format(transfer_uuid)
)
Expand Down Expand Up @@ -379,7 +377,6 @@ def _import_pipeline_dependant_transfer(
"Skipping transfer {} - not found in the database!".format(transfer_uuid)
)
return
cmd.info("Indexing {} ({})".format(transfer_uuid, transfer_dir))
elasticSearchFunctions.index_transfer_and_files(
es_client,
transfer_uuid,
Expand Down

0 comments on commit 60b6c80

Please sign in to comment.