readthedocs-fr / bin-server

Un outil pour héberger des snippets de code et les partager via une URL.
https://bin.readthedocs.fr
MIT License
14 stars 15 forks source link

imp: prevent bin overwriting #76

Closed Mesteery closed 3 years ago

Mesteery commented 3 years ago

Closes: #64.

A bin can currently overwrite another one, if it has the same identifier. This will prevent overwriting, by generating an ID until it is not already taken.

fusetim commented 3 years ago

Even if it is very unlikely, add a max retry limit would be great.

Mesteery commented 3 years ago

Why not, but what should be returned to the user? This is an unlikely case, he will inevitably end up finding a free identifier.

fusetim commented 3 years ago

I really don't like the idea of having a possible infinite loop. I suppose a Internal Server Error could be sufficient. Maybe, we need more reviewers to express their thoughts on that

Julien00859 commented 3 years ago

+1 for a watchdog


for watchdog in range(20):
    indent = ...
    if not database.exists(ident):
        break
else:
    raise RuntimeError("Woof")```