From 7c954e97d1c6c590618aa298ca5417a2e8c83615 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sat, 20 Sep 2025 14:51:34 -0400 Subject: make sure keys are unique --- pypaste/server/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pypaste/server/__init__.py b/pypaste/server/__init__.py index 67f8771..1c13960 100644 --- a/pypaste/server/__init__.py +++ b/pypaste/server/__init__.py @@ -190,7 +190,14 @@ class App: text="content must be unicode only, no binary data is allowed" ) - key = generate_key(self.config.dictionary, self.config.key_length) + try: + while await self.storage.exists( + (key := generate_key(self.config.dictionary, self.config.key_length)) + ): + pass + except Exception as e: + log_error(str(e)) + return web.HTTPInternalServerError() try: paste = Paste(key, datetime.now(), syntax, text) -- cgit v1.2.3