summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-20 14:51:34 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-20 15:27:17 -0400
commit7c954e97d1c6c590618aa298ca5417a2e8c83615 (patch)
tree289234cb6a640265ed1bb16d60ff70074d2c7774
parent10bf75f6043125bc178e823a940ecc9e7572706f (diff)
downloadpypaste-7c954e97d1c6c590618aa298ca5417a2e8c83615.tar.gz
make sure keys are unique
-rw-r--r--pypaste/server/__init__.py9
1 files changed, 8 insertions, 1 deletions
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)