From 0df43a351fbc9369834cb8707550eb500589c9fe Mon Sep 17 00:00:00 2001 From: Alex <akreft@trineo.org> Date: Wed, 21 Apr 2021 16:11:41 +0200 Subject: [PATCH] Split large container for deletion. --- src/caosdb/common/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 39d9e38d..c1e0ee39 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -2804,6 +2804,17 @@ class Container(list): this happens, none of them will be deleted. It occurs an error instead. """ + chunk_size = 100 + item_count = len(self) + # Split Container in 'chunk_size'-sized containers (if necessary) to avoid error 414 Request-URI Too Long + if item_count > chunk_size: + for i in range(0, int(item_count/chunk_size)+1): + chunk = Container() + for j in range(i*chunk_size, min(item_count, (i+1)*chunk_size)): + chunk.append(self[j]) + if len(chunk): + chunk.delete() + return if len(self) == 0: if raise_exception_on_error: -- GitLab