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