Commit f8d44987 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added bulk delete of upload calcs.

parent c602733f
......@@ -334,6 +334,14 @@ def delete_archive(archive_id: str):
raise KeyError()
def delete_archives(upload_hash: str):
""" Delete all archives of one upload with the given hash. """
bucket = config.files.archive_bucket
objects = _client.list_objects(bucket, '%s/' % upload_hash)
for _ in _client.remove_objects(bucket, [obj.object_name for obj in objects]):
pass
def external_objects_url(url):
""" Replaces the given internal object storage url (minio) with an URL that allows
external access. """
......
......@@ -91,6 +91,7 @@ class Calc(Proc):
"""
Delete this calculation and all associated data. This includes all files,
the archive, and this search index entry.
TODO is this needed? Or do we always delete hole uploads in bulk.
"""
# delete the archive
if self.archive_id is not None:
......@@ -254,8 +255,14 @@ class Upload(Proc):
logger.debug('Upload exist, but uploaded file does not exist.')
with lnr(logger, 'deleting calcs'):
for calc in Calc.objects(upload_id=self.upload_id):
calc.delete()
# delete archive files
files.delete_archives(upload_hash=self.upload_hash)
# delete repo entries
RepoCalc.search().query('match', upload_id=self.upload_id).delete()
# delete calc processings
Calc.objects(upload_id=self.upload_id).delete()
with lnr(logger, 'deleting upload'):
super().delete()
......
......@@ -192,3 +192,14 @@ def test_delete_archive(archive_id: str):
pass
else:
assert False
def test_delete_archives(archive_id: str):
files.delete_archives(archive_id.split('/')[0])
try:
files.archive_url(archive_id)
assert False
except KeyError:
pass
else:
assert False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment