handled bug cannot create secret in empty file
This commit is contained in:
parent
334bb97d35
commit
3f1ddacce3
6
main.py
6
main.py
@ -131,7 +131,11 @@ async def create_secret(secret: Secret, current_user: dict = Depends(get_current
|
||||
text = f.read()
|
||||
if text:
|
||||
data.extend(json.loads(text))
|
||||
secret_id = max(i['id'] for i in data) + 1
|
||||
|
||||
if data:
|
||||
secret_id = max(i['id'] for i in data) + 1
|
||||
else:
|
||||
secret_id = 0
|
||||
secret.id = secret_id
|
||||
secret.user_id = current_user['id']
|
||||
encryption_key = current_user['encryption_key'].encode()
|
||||
|
Loading…
Reference in New Issue
Block a user